![](/img/trans.png)
[英]iOS - Change a ViewController with the keyboard “next” button?
[英]change automatically to next ViewController
以下情況。
在情節提要中,我有兩個ViewController。 ViewController_1和ViewController_2 。 當第一個ViewController_1打開並且viewdidload void被加載時,如何在一定時間( 我可以調整 )之后自動移動到下一個ViewController_2 ,而無需任何用戶干預? 我正在為我的方法使用此自我呼喚:
[self performSelector:@selector(toNewViewController:) withObject:nil
afterDelay:timeInSeconds];
但是我不確定如何使用視圖控制器編寫方法以查看控制器轉換。 有任何想法嗎?
從第一個視圖到第二個視圖,在情節提要中創建序列(從一個視圖到另一個視圖的箭頭)。
然后,您需要調用toNewViewController
方法:
[self performSegueWithIdentifier:@"nameOfYourSegue" sender:self];
此調用將執行從第一個視圖到第二個視圖的過渡。
首先,您必須創建一個函數,該函數將顯示您的第二個ViewController。
[NSTimer scheduledTimerWithTimeInterval:certainTime target:self selector:@selector(presentnextView) userInfo:nil repeats:NO];
-(void)presentnextView
{
ViewController *secondView=[[ViewController alloc] init];
[self presentViewController:secondView animated:YES completion:nil];
[secondView release];
}
您可能還需要此方法來攔截控制器傳輸並設置目標視圖控制器:
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"nameOfYourSegue"]) {
/* In my case its navigation controller, for you it may be different */
UINavigationController *navi = [segue destinationViewController];
ComposeViewController *compose = [navi.viewControllers objectAtIndex:0];
compose->delegate = self;
compose.login = self.login;
compose.name = self.name;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.