开发者

Specific iPad modal view

Okay, I am still learning how to program and things are moving along quite well, but I have a question for the group about something that has been plaguing me:

How do I create a pop view where the background can still be seen? I mean, say my iPad view has 5 buttons on it, and I want a small square to pop up over where that button was, asking the user a question - how would i do that? Can I make a modal view with an开发者_运维技巧 invisible background? (I don't want a UIAlert BTW - I know that would solve my problem, but I am trying to learn how to do this with my own view)

Can anyone point me in the right direction?


You say "pop view" which makes me think you're describing a popover. Have you read the iPad Programming Guide, specifically, the section "Creating and Presenting a Popover"? It really is required reading in this case.

Are you showing the popover from a bar button? If so, you'll want to use presentPopoverFromBarButtonItem:permittedArrowDirections:animated:. If not, you'll need to identify a CGRect that represents the button (you can use its bounds), and then use presentPopoverFromRect:inView:permittedArrowDirections:animated:.

You do not want to obscure the button with the popover. When you show the popover using the above methods, the framework will take care of positioning the popover on-screen. Use the UIPopoverArrowDirectionAny for directions whenever possible.

If you actually want to show a modal view, you can create whatever view you want and then display it in such a way that the background is not fully obscured. Just set the modalPresentationStyle of the view controller to something like UIModalPresentationPageSheet.


You should create a custom UIView with the dimensions and content that you want to display. Then, you can place the custom UIView on screen by calling something like:

//where 'self' is the view controller currently visible and 'customView' is 
//the view which has the question for the user.  Don't forget to set the 
//frame property on customView so that it knows the correct place to display.
[self.view addSubview:customView];

Hope this helps. Andrew

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜