views:

60

answers:

3

How would i show that the progress bar is working there is no Refresh() in objective-c like there is in .net what would i use

for example

contactprogress.progress = 0.5;   
StatusLabel.text = @"Status: Address Found";

How would i refresh the view to show that the progress has changed & show user the StatusLabel status?

Thanks

Mason

A: 

To redraw an UIView, you can use

[UIView setNeedsDisplay];

However, you will need this only in very rare cases. When you change, let's say the contents of a label, your UI should update instantly. You might want to provide more code/context for your problem.

Phlibbo
contactprogress.progress = 0.25; StatusLabel.text = @"Status: Finding address's"; ABAddressBookRef _addressBookRef = ABAddressBookCreate (); NSArray* allPeople = (NSArray *)ABAddressBookCopyArrayOfAllPeople(_addressBookRef); NSMutableArray* _allItems = [[NSMutableArray alloc] initWithCapacity:[allPeople count]]; // capacity is only a rough guess, but better than nothing
that didnt work just terminated the app
Please add the code to your inital posting, reading it in a comment isn't very comfortable. But generally, if you have StatusLabel.text = @"Status: Finding address's"; and nothing happens, there is something wrong with your setup. If you have used Interface Builder, did you connect the Label to the "StatusLabel"-variable? Concerning the termination: Replace the "UIView" with the reference to your UIView, i.e. [self setNeedsDisplay]
Phlibbo
Status label works fine once the task is complete
Well, you didn't mention that you are doing this while a task is running.
Phlibbo
Ohh yes sorry :/
A: 

It sounds like you want to update a progress bar and some text repeatedly with some time interval between. You could use a simple timer. Read about timers here. Perhaps something like this:

[NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(refreshProgress) userInfo:nil repeats:YES];

and:

- (void) refreshProgress:(id)sender {
  // figure out new progress bar and text values
  contactprogress.progress = 0.5;   
  StatusLabel.text = @"Status: Address Found";

  // check if we should stop the timer and hide the progress bar/status text
}

That would update your progress bar with new values every 0.1 seconds.

No Surprises
Sorry this will not work for what i want
Maybe you could update your post to be more clear about what you're trying to do and what's going wrong ...
No Surprises
basically the contactprogress jsut goes from 0 to 1 without showing the stages, the task is taking atleast 1 minute so its not asif its as the task is too fast
+1  A: 

Based on your comments to the other two responses, you're doing some computationally intensive task that takes a few seconds, and the view is not updating during the task. You could try using two threads (not as scary as it sounds) so that the UI can continue updating while the task is doing its thing.

Here is an example.

iOS Reference Library Threading Programming Guide

No Surprises