简体   繁体   中英

If UIProgressView.progress is moving

I'm new to Xcode.

I need a If Statement that asks IF the UIProgressView progress (float) goes bigger or smaller then do something.

Thanks for any help.

if (myProgV is moving) {

//Do something

}

As the others have hinted, you've got this backwards. A progress view is a view object. It displays things. It is not supposed to save state information.

You should read up on the MVC design pattern. View objects should not be used to store things.

I would suggest adding a property to your view controller. Let's call it progress. Say it has a value that ranges from 0 to 1.

Implement a custom setter for your progress property that sets a progress view, and also saves the value to the property's instance variable:

- (void) setProgress: (CGFloat) progress;
{
   _progress = progress;
   [myProgressView setProgress: progress animated: yes];
   //Do anything else here that you need to to respond to a change in progress.
}

Now, since you have a property, you can also query the value of progress at any point:

if (self.progreess > .5) 
  NSLog(@"More than halfway done!");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM