1. 程式人生 > >純程式碼跳轉到xib介面以及storyboard介面

純程式碼跳轉到xib介面以及storyboard介面

現在在iOS開發中,有三種開發UI的方式,純程式碼,xib,storyboard。我是喜歡用純程式碼開發的,但是專案中總會有人用其他的方式,那麼怎麼進行跳轉呢?下面分別介紹
1,跳轉到xib
假設有一個按鈕,這個按鈕就是實現跳轉的,那麼在這個按鈕的點選事件中,程式碼可以這樣寫。
AViewController *a1= [[AViewController alloc]initWithNibName:@”AViewController” bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:a1 animated:YES];
2,跳轉到storyboard
如上,程式碼可以這樣寫
UIStoryboard *sb=[UIStoryboard storyboardWithName:@”A” bundle:nil];
[self presentViewController:[sb instantiateInitialViewController] animated:YES completion:nil];