您的位置:首页 > 移动开发

关于viewDidLoad里调用presentModalViewController的问题

2012-03-22 12:31 344 查看
原贴地址:http://www.cocoachina.com/bbs/read.php?tid=97273

------------------------------------------------------------------------------------------------------------------------------------------------------
- (void)viewDidLoad 里调用presentModalViewController无效果,

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions里调用presentModalViewController就有效果

加个button,在button点击事件里调用presentModalViewController也没有问题

表示非常迷惑,为什么- (void)viewDidLoad 里调用presentModalViewController就没有效果呢。

明眼的大神帮忙解释下吧- -

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

在(void)viewDidAppear:(BOOL)animated里面调用吧

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

最后分享一个利用presentModalViewController方法制作的启动动画吧,大神见笑了

- (void)viewDidAppear:(BOOL)animated{
[loginViewController presentModalViewController:welcomeViewController animated:NO];
[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(dismissModalView) userInfo:nil repeats:NO];
}
- (void)viewDidLoad {
[super viewDidLoad];
loginViewController = [[UIViewController alloc] init];
loginViewController.view.frame = [[UIScreen mainScreen] bounds];
loginViewController.view.backgroundColor = [UIColor redColor];
[self.view addSubview:loginViewController.view];

welcomeViewController = [[UIViewController alloc] init];
welcomeViewController.view.frame = [[UIScreen mainScreen] bounds];
UIImageView *welcomeImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Default.png"]];
welcomeImageView.frame = CGRectMake(0, 0, 320, 460);
[welcomeViewController.view addSubview:welcomeImageView];
}
- (void)dismissModalView{
welcomeViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[welcomeViewController dismissModalViewControllerAnimated:YES];
}
资源地址:http://download.csdn.net/detail/liyan5953wow/4162557
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  application button