Today I will show everyone how to build a simple application (with some basic customization) that will display a progressview and a button. When the button is clicked the progressview will start.
If you need any help comment below and I will respond as soon as I can
this is the basic operation of the ProgressView. But the problems are comming when you try to use it for monitoring the running of a function.
Do you have a solution for that? I have tried multi threading, but it fails. NSTimer is also not working as it is just called when the software is in idle (so out of a function called by an interaction).
great tutorials. I am waiting for your tips and tricks too. If you do not mind I submit here my solution for the problem I have mentioned above. The main problem is that if you would like to monitor the progress of a subroutine, the iPhone GUI is not updating until you reach the end of the function. So what ever you would like to display will not be updated until then. This means that the progress bar will also not updated. You need a workaround of this by detaching a GUI update function from the current running loop.
Here is the example:
- (void) FunctionA {
—– this function you plan to monitor ——
NSString *myString=@”This message to be displayed…”;
Ahh… Nice, however if you are creating a game never use a code like that. because there will be issues in your game. I’ve tried it and been rejected by Apple for some “random” memory leaks!
Good job though :)
5 Responses
Hi,
this is the basic operation of the ProgressView. But the problems are comming when you try to use it for monitoring the running of a function.
Do you have a solution for that? I have tried multi threading, but it fails. NSTimer is also not working as it is just called when the software is in idle (so out of a function called by an interaction).
Thanks
Endre
Hi,
great tutorials. I am waiting for your tips and tricks too. If you do not mind I submit here my solution for the problem I have mentioned above. The main problem is that if you would like to monitor the progress of a subroutine, the iPhone GUI is not updating until you reach the end of the function. So what ever you would like to display will not be updated until then. This means that the progress bar will also not updated. You need a workaround of this by detaching a GUI update function from the current running loop.
Here is the example:
- (void) FunctionA {
—– this function you plan to monitor ——
NSString *myString=@”This message to be displayed…”;
[NSThread detachNewThreadSelector:@selector(HandleProgressBarStatus:) toTarget:self withObject:myString];
}
——- Progress Bar Update function ———
- (void) HandleProgressBarStatus:(NSString *) Message {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
[MessageLabel setText:[NSString stringWithFormat:@"%@ - %0.1f%%",Message,(ProgressStatus/ProgressStatusMaxValue)*100.0]];
[MessageLabel setTextColor:[UIColor redColor]];
[myProgressBar setProgress:(ProgressStatus/ProgressStatusMaxValue)];
[pool release];
}
ProgressStatus and ProgressStatusMaxValue are defined as class variables and values are given within the monitored function.
In the same way you can create an AlertView or anything else. The processing of the monitored function will not block the update of the GUI.
I hope this short example saves you some time.
Thanks for your efforts to provide help for us!
Regards
Endre
Ahh… Nice, however if you are creating a game never use a code like that. because there will be issues in your game. I’ve tried it and been rejected by Apple for some “random” memory leaks!
Good job though :)
Thanks Shayan. This video helps me to complete my assignment. Nice work. :)
your definitely welcome!