dismissmodalviewcontrollerjsanimatedimagesview 被换成什么了

presentModalViewController和dismissModalViewControllerAnimated的使用总结
在实际开发中,如果要弹出视图:
我们常用到presentModalViewController方法和dismissModalViewControllerAnimated方法。
presentModalViewController:弹出视图
dismissModalViewControllerAnimated:隐藏视图
弹出视图:
FeedbackViewController *feedbackViewController =
[[FeedbackViewController alloc]
initWithNibName:@"FeedbackViewController" bundle:nil];
& & UINavigationController
*navigationController = [[UINavigationController alloc] initWithRootViewController:feedbackViewController];
presentModalViewController:navigationController animated:YES];
隐藏视图:
dismissModalViewControllerAnimated:YES];
关于这两个方法的几点说明:
1.iPhone上弹出/隐藏 视图时,使用为全屏模式
On iPhone and iPod touch devices, the view
of&modalViewController&is
always presented full screen.
2.搞清楚谁是presenting,谁是presented
如果A弹出B,那么A为presenting,B为presented。
3.隐藏视图的策略
The presenting view controller is responsible for dismissing the
view controller it presented. If you call this method on the
presented view controller itself, however, it automatically
forwards the message to the presenting view
controller.
我们假如A弹出B
就是说,A负责隐藏B;如果我们在B中调用dismissModalViewControllerAnimated方法,那么编译器,自动将消息发送给A。
等等,什么消息?
简单的理解,当执行presentModalViewController:方法:在A弹出B时:
执行A的viewWillDisappear方法,
通知B执行自己的viewWillAppear方法和viewDidAppear方法
执行A的viewDidDisappear方法
当执行dismissModalViewControllerAnimated方法:隐藏B时:
执行B的viewWillDisappear
通知A执行自己的viewWillAppear方法和viewDidAppear方法
执行B的viewDidDisappear方法
以下我做了个测试来输出一轮AB切换:
14:01:23.666 WTV[]
-More--viewWillDisappear----
14:01:23.672 WTV[]
-Feed--viewWillAppear----
14:01:24.086 WTV[]
-Feed--viewDidAppear----
14:01:24.087 WTV[]
-More--viewDidDisappear----
14:01:25.745 WTV[]
-Feed--viewWillDisappear----
14:01:25.745 WTV[]
-More--viewWillAppear----
14:01:26.156 WTV[]
-More--viewDidAppear----
14:01:26.157 WTV[]
-Feed--viewDidDisappear----
当我们信心慢慢,庆幸我们可以了解了这两个方法时,悲剧发生了:
4.苹果官方已经把这两个方法&Deprecated
in iOS 6.0.&了
(void)presentModalViewController:(UIViewController
*)modalViewController animated:(BOOL)
(void)dismissModalViewControllerAnimated:(BOOL)
取而代之的是:
[self presentViewController:navigationController
animated:YES
& & completion:^(void){
dismissViewControllerAnimated:YES
completion:^(void){
& & //&Code
新接口的差别是提供了一个参数,允许你传入一个block。这个block的回调方法在VC的viewWillDisappear方法后调用。也就是被隐藏的VC对象被释放后运行回调。
这样做的好处:可以方便做多个UI效果之间的衔接和转换。
用新的吧!与时俱进!
希望对你有所帮助!
已投稿到:
以上网友发言只代表其个人观点,不代表新浪网的观点或立场。二次元同好交流新大陆
扫码下载App
汇聚2000万达人的兴趣社区下载即送20张免费照片冲印
扫码下载App
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
彪悍的人生不需要解释,彪悍的代码不需要注释
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
我们常用到presentModalViewController方法和dismissModalViewControllerAnimated方法。
presentModalViewController:弹出视图
dismissModalViewControllerAnimated:隐藏视图
弹出视图:
FeedbackViewController *feedbackViewController =
[[FeedbackViewController alloc]
initWithNibName:@"FeedbackViewController" bundle:nil];
& & UINavigationController
*navigationController = [[UINavigationController alloc] initWithRootViewController:feedbackViewController];
presentModalViewController:navigationController animated:YES];
隐藏视图:
dismissModalViewControllerAnimated:YES];
关于这两个方法的几点说明:
1.iPhone上弹出/隐藏 视图时,使用为全屏模式
On iPhone and iPod touch devices, the view
of&modalViewController&is
always presented full screen.
2.搞清楚谁是presenting,谁是presented
如果A弹出B,那么A为presenting,B为presented。
3.隐藏视图的策略
The presenting view controller is responsible for dismissing the
view controller it presented. If you call this method on the
presented view controller itself, however, it automatically
forwards the message to the presenting view
controller.
我们假如A弹出B
就是说,A负责隐藏B;如果我们在B中调用dismissModalViewControllerAnimated方法,那么编译器,自动将消息发送给A。
等等,什么消息?
简单的理解,当执行presentModalViewController:方法:在A弹出B时:
执行A的viewWillDisappear方法,
通知B执行自己的viewWillAppear方法和viewDidAppear方法
执行A的viewDidDisappear方法
当执行dismissModalViewControllerAnimated方法:隐藏B时:
执行B的viewWillDisappear
通知A执行自己的viewWillAppear方法和viewDidAppear方法
执行B的viewDidDisappear方法
以下我做了个测试来输出一轮AB切换:
14:01:23.666 WTV[]
-More--viewWillDisappear----
14:01:23.672 WTV[]
-Feed--viewWillAppear----
14:01:24.086 WTV[]
-Feed--viewDidAppear----
14:01:24.087 WTV[]
-More--viewDidDisappear----
14:01:25.745 WTV[]
-Feed--viewWillDisappear----
14:01:25.745 WTV[]
-More--viewWillAppear----
14:01:26.156 WTV[]
-More--viewDidAppear----
14:01:26.157 WTV[]
-Feed--viewDidDisappear----
当我们信心慢慢,庆幸我们可以了解了这两个方法时,悲剧发生了:
4.苹果官方已经把这两个方法&Deprecated
in iOS 6.0.&了
(void)presentModalViewController:(UIViewController
*)modalViewController animated:(BOOL)
(void)dismissModalViewControllerAnimated:(BOOL)
取而代之的是:
[self presentViewController:navigationController
animated:YES
& & completion:^(void){
dismissViewControllerAnimated:YES
completion:^(void){
& & //&Code
新接口的差别是提供了一个参数,允许你传入一个block。这个block的回调方法在VC的viewWillDisappear方法后调用。也就是被隐藏的VC对象被释放后运行回调。
这样做的好处:可以方便做多个UI效果之间的衔接和转换。
阅读(2515)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'presentModalViewController和dismissModalViewControllerAnimated的使用总结',
blogAbstract:'在实际开发中,如果要弹出视图:\n我们常用到presentModalViewController方法和dismissModalViewControllerAnimated方法。\n\npresentModalViewController:弹出视图\n\ndismissModalViewControllerAnimated:隐藏视图\n\n贴代码:\n\n弹出视图:\n\n',
blogTag:'',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:4,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'彪悍的人生不需要解释,彪悍的代码不需要注释',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}

我要回帖

更多关于 ion modal view 的文章

 

随机推荐