开发者

i*-sdk: Placing a bubble on top of all controls

开发者 https://www.devze.com 2023-01-15 12:50 出处:网络
I\'ve got a problem thats been perplexing me for a while. I have a custom control for the iPhone sdk. When the user touches the control I want to draw a small bubble above the users touch position wit

I've got a problem thats been perplexing me for a while. I have a custom control for the iPhone sdk. When the user touches the control I want to draw a small bubble above the users touch position with some information in it. A bit like a thought bubble in a cartoon.

Initially I've done it by adding a UIView subview to the control. However if I use the control where I don't have control of the z-order, for example in a table view, then the bubble will be drawn under other controls.

I've looked around but I'm not sure how to approach this problem. Everything I've read seems to indicate that you need to know the tree structure of the controls. Ideally I'd like to apply it to some layer that sits over the window as a whole, but I'm not sure how. I've also look at core graphics but can开发者_StackOverflownot see any obvious answers.

Does anyone have any ideas of perhaps something they can point me at which will help.

Thanks


If you want to add a UIView to the 'top window', you can use the application UIWindow for that.

UIWindow is a subclass of UIView, so you can just use - (void)addSubview:(UIView *)view to add the new view to the window.

[[UIApplication sharedApplication] keyWindow] addSubview:yourView];


You could try adding it as a subview of the window, though, I don't think that's the most appropriate solution.

Personally, I would add my control as a subview to whichever view (maybe a table cell) and then tell that view to bring your control to the front.

[tablecell bringSubviewToFront:myControl];

That way, when you display your bubble, it'll be on top.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号