开发者

Present a UIView over a view

开发者 https://www.devze.com 2023-01-15 23:42 出处:网络
How can I make 开发者_如何转开发a custom view in iOS which appears above the existing view,but smaller? It should be like UIAlertView, but taken from a .xib file. After user taps a certain button, the

How can I make 开发者_如何转开发a custom view in iOS which appears above the existing view,but smaller? It should be like UIAlertView, but taken from a .xib file. After user taps a certain button, the small view vanishes and the normal view appears.

If this is posiible, how can I do it? And.. if it's not hard for you, please, include code.

Thanks in advance!


I think what you're looking for is a modal view. Modal views make it easy to have a view take over the screen for a little while, then when they get dismissed have the background view resume where it left off without having to worry about who's on top or handling events in partially-obscured views.

Here is Apple's article describing it.

They key is to have the controller class for your view call [self presentModalViewController:popupController animated:YES]; where "popupController" is the view controller for the view you want to show up. When you're ready to make it go away, call [self dismissModalViewControllerAnimated: YES];


You can just use the addSubview: method on your UIWindow or your visible UIViewController's view to show the UIView, and you can hide/remove it later by calling removeFromSuperview on the presented UIView.

0

精彩评论

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