I have a view 200 x 150 px which i would like to present o开发者_如何学JAVAn the tap of a button. If i use addSubview:
then the view shows up in the correct position, but i can still tap other buttons on the superview, which is behaviour i don't want.
If i use presentModalViewController
then the view takes up the whole screen, which is what i don't want either... this happens even if i set wantsFullScreenLayout
to NO
.
How can i present the view so that the user can only interact with controls on the presented view?
Thanks
Make the view the size of the screen (taking the status bar into account). That view should have a translucent background color (or clear). Have the 200x150 view be on the bottom of that view to have the appearance of a UIActionSheet, where the background dims and the user cannot interact with other elements on the screen.
Then, you can use presentModalViewController
to present the view.
Addition
In the view controller's .m file, define awakeFromNib:
-(void)awakeFromNib
{
self.view.backgroundColor = [UIColor clearColor];
}
精彩评论