iOS故事板下使用代碼跳轉頁面

現在iOS8下,使用Storyboards開發十分方便,搭配上Size Class後,而且適配更加便捷。ide

可是忽然由代碼寫界面或者xib轉向故事板,不免有一些疑惑。spa

因爲故事板下,基本使用連續來跳轉頁面,但有些狀況下總會用到代碼控制頁面跳轉,這個時候傳統的初始化ViewController後push過去會出現一個黑色屏幕,什麼內容都沒用。code

解決方案:blog

UIStoryboard *story = [UIStoryboard storyboardWithName:@"填寫故事板名稱" bundle:nil];
UIViewController *vc = [story instantiateViewControllerWithIdentifier:@"填寫ViewController在故事板中設置的identifier"];

[vc setModalPresentationStyle:UIModalPresentationFullScreen];

[self.navigationController pushViewController:vc animated:YES];開發

相關文章
相關標籤/搜索