当执行此操作时,它直接显示secondviewcontroller我想要的是viewcontroller首先显示,在40或50秒之后它会显示nextviewcontroller next,依此类推。
- (void)displayviewsAction:(id)sender
{
PageOneViewController *viewController = [[PageOneViewController alloc] init];
viewController.view.frame = CGRectMake(0, 0, 320, 480);
SecondViewController *secondController = [[SecondViewController alloc] init];
secondController.view.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:viewController.view];
[self.view addSubview:secondController.view];
[self.view bringSubviewToFront:viewController.view];
[self.view addSubview:toolbar];
[self.view sendSubviewToBack:viewController.view];
[self.view addSubview:toolbar];
}
任何人都有任何想法,我怎么能这样做。
答案 0 :(得分:2)
尝试使视图不可见,然后在40秒后快速淡入。
secondController.view.alpha = 0.0;
[self.view addSubview:secondController.view];
[UIView animateWithDuration:0.5
delay:40
options:UIViewAnimationCurveEaseInOut
animations:^{
secondController.view.alpha = 1.0;
}
completion:NULL
];
答案 1 :(得分:1)
您可以在单独的方法中添加secondViewController,并使用 performSelector:withObject:afterDelay
调用该方法- (void)displayviewsAction:(id)sender {
PageOneViewController *viewController = [[PageOneViewController alloc] init];
viewController.view.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:viewController.view];
[self performSelector:@selector(secondViewController) withObject:nil afterDelay:40];
}
-(void)secondViewController {
SecondViewController *secondController = [[SecondViewController alloc] init];
secondController.view.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:secondController.view];
}
答案 2 :(得分:1)
Aravindhanarviless详述的方法的替代/补充是使用NSTimer:
self.myTimer = [NSTimer scheduledTimerWithTimeInterval:40 target:self selector:@selector(showSecondViewController) userInfo:nil repeats:NO];