cocoatips
cocoatips
Just few lines of codes
8 posts
Don't wanna be here? Send us removal request.
cocoatips 13 years ago
Text
UIActivityIndicatorView over an UIButton
Did you know that putting an UIActivityIndicatorView over a UIButton, all touch events are blocked by the spinner?
If you do the same with a UILabel or UIImageView, all events are forwarded to the button (its superview), like I (and you) expect. But with UIActivityIndicatorView this is not the behaviour you get. All these classes are extensions of UIView, so why they work differently?
The key difference is that the UIActivityIndicatorView is animated. When you have an animated view, iOS changes its userInteractionEnabled property to YES to prevent interactions (and interruptions) from the user with that view, during the animation phase.
How to fix that? Just set userInteractionEnabled to NO on the spinner, so all the touch events are forwarded again to the spinner superview (the button in my case) and everything works like I expect.
Here is the example code
spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
[spinner startAnimating];
[spinner setUserInteractionEnabled:NO]; // setting UserInteractionEnable to NO, any touch events are forwarded to the superview (the button)
聽聽 聽 聽 聽 spinner.center = CGPointMake(20, 18);
[self addSubview:spinner];
Bug fixed. Let's move on...
0 notes
cocoatips 14 years ago
Link
0 notes
cocoatips 14 years ago
Link
0 notes
cocoatips 14 years ago
Link
0 notes
cocoatips 14 years ago
Link
0 notes
cocoatips 14 years ago
Link
0 notes
cocoatips 14 years ago
Link
0 notes
cocoatips 14 years ago
Text
Let's do this!
Hi everyone!聽
It has been quite some time since I wanted to open a space where talk about iOS SDK. And today it's time to start it!
I don't want to create a long posts blog, I don't have time for that.
I wanna share with you just handy tips and tricks I learned and found around the world while working with iOS SDK, since version 3.0.
I hope someone find these snippets somehow useful.
So, let's do this!
0 notes