您现在的位置: IOS教程網 >> IOS系統 >  >> iOS 訊息 >> iOS 相關資訊

多個 Storyboard 之間跳轉

編輯:iOS 相關資訊

Storyboard 並非只能有一個。大型專案中,可依功能將畫面拆分到不同 Storyboard,讓流程更清楚,也減少單一檔案過於龐大。

若要從目前 Storyboard 跳到另一個 Storyboard 的 view controller,可先建立 UIStoryboard 物件,再以 instantiateViewControllerWithIdentifier: 取得目標控制器,最後用 navigation controller push。

UIStoryboard *secondStoryBoard = [UIStoryboard storyboardWithName:@"Storyboard2" bundle:nil];
UIViewController *test2 = [secondStoryBoard instantiateViewControllerWithIdentifier:@"test2"];
[self.navigationController pushViewController:test2 animated:YES];

這裡的 test2 是目標 view controller 在 Interface Builder 中設定的 Storyboard ID。只要 ID 正確,就能在不同 Storyboard 之間自由跳轉。

  1. 上一篇文章:
  2. 下一篇文章:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © IOS教程網 All Rights Reserved