How to set the type of activity indicator in iOS

In .hfile:

UIActivityIndicatorView *mySpinner;

In viewDidLoad:

mySpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
mySpinner.center = CGPointMake(160, 240);
mySpinner.hidesWhenStopped = YES;
[self.view addSubview:mySpinner];

and finally, I find it by pressing a button:

[mySpinner startAnimating];

The problem is that when I called it in viewDidLoad, it showed and started the animation, but the animation didn’t even show when the button was pressed. Help me in this matter.

Thanks in advance

+3
source share
2 answers

Thanks to everyone who helped me .... I solved the problem, and here I am posting an answer for those who are looking for this ... in fact, the problem is that "I am loading some records by synchronous request. Therefore, why the update The user interface is locked for a while.

therefore the problem arises here ....

. "", , "start"

[NSThread detachNewThreadSelector: @selector(Start) toTarget:self withObject:nil];

"start" -

- (void) Start
{
Spinner.hidden = NO;
[mySpinner startAnimating];
}
+2

, 'mySpinner "ivar .

.h . :

@property (strong) UIActivityIndicatorView *mySpinner;

, :

self.mySpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];

:

[self.mySpinner startAnimating];
+2

All Articles