GeekedOut
GeekedOut

Reputation: 17185

UIActivityIndicatorView spinner not showing up

I am trying to get my first spinner to work, and I can't seem to get it to show up on the screen.

I tried dragging the UIActivityIndicatorView on the storyboard to my screen, but then when I tried to connect it to my header file via the storyboard, it didn't seem to respond. (what are the correct steps there?)

So I did it manually. I added this line to my .h file:

@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *aSpinner;

and then I added these lines to my .m file

UIActivityIndicatorView   *aSpinner; 

//throw up spinner from submit btn we created
aSpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:
            UIActivityIndicatorViewStyleWhiteLarge];

[self.view addSubview:aSpinner]; 
[aSpinner startAnimating]; 

but when I ran the test, no spinner showed up. Any thoughts on what I am doing incorrectly here?

Upvotes: 0

Views: 3072

Answers (2)

Mert
Mert

Reputation: 6065

Select your spinner in your nib file right click -> click & drag from reference to files owner. Then select aSpinner.

It does not show up, because activityindicator in nib and your code are not connected.

Upvotes: 1

JKvr
JKvr

Reputation: 649

You should use "strong" instead "weak" in the @property line.

The UIActivityIndicatorView is freed directly if weak is used and you don't want that.

Maybe you should set a frame to the view as well.

Upvotes: 0

Related Questions