如何从视图1切换到视图2,而无需按任何按钮。在我的意见,我有是的UIImageView和UITextView的从视图1切换到视图2,不用按任何按钮
随着IM的NSTimer试图通过使用下面的代码中viewDidLoad方法来做到这一点
:
在firstviewcontroller.h文件
@interface FirstViewController : UIViewController
{
NSTimer *SwitchingTimer;
}
在firstviewcontroller.m文件
- (void)viewDidLoad
{
[super viewDidLoad];
SwitchingTimer = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(SwitchView) userInfo:nil repeats:YES];
}
-(void)SwitchViews:(id)sender
在secondviewcontroller.m文件中
-(void) SwitchView
{
SecondViewController *SecondView = [[SecondViewController alloc]
initWithNibName:@"SecondViewController" bundle:nil];
SecondView.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:SecondView animated:YES];
[SwitchingTimer invalidate];
self.SwitchingTimer = nil;
}
但是什么也没有发生。有人可以告诉我我的代码中缺少什么。将感谢帮助。
在此先感谢。
请注意,使用ARC时,'SwitchView'不再泄漏。 – fabian789 2011-12-29 10:12:32
@ fabian789指出并回答更新。谢谢 :) – visakh7 2011-12-29 10:16:32