※ 引述《chk95 (真男人魂)》之銘言:
: 主要是在b.m檔裡面呼叫a.h檔的原件做更新資料的動作
: 程式大致如下
: NewsController* newController =
: [self.storyboard instantiateViewControllerWithIdentifier:@"NewsPages"];
: [self.navigationController pushViewController:newController animated:YES];
: newController.title = @"abcd";
: newController.newsPage_textView.text=@"oh ya";
你用lldb設breakpoint在這一行看看
newsPage_textView一定是nil
因為這個時候newController裡的view還沒load進來
此時newController只有init而已
因為pushViewController後並非馬上顯示
而是等到runloop結束後
才會統一更新畫面
此時才會去access controller的view
其subview才會通通被load進來
你可以做個實驗
在newController.newsPage_textView.text=@"oh ya";之前
加上一行newController.view;
這樣就可以抓到newsPage_textView了
所以一般的做法
要等到viewDidLoad才抓得到news_textView
建議你把view controller的文件讀過一次
才會瞭解iOS的view是如何運作的
https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/ViewLoadingandUnloading/ViewLoadingandUnloading.html
懶得讀的話直接看Figure4-1那張圖
: 在xcode尚未更新為5.02時,執行這個程式都可順利改寫title以及newsPage_textView
: 的資料並秀出,但xcode更新後再次執行此專案才發現title順利改寫了
: 但newsPage_textView卻無法更新資料
: storyboard id也有做定義
: 在a.m檔執行newsPage_textView改寫資料也可以順利改寫
: 唯獨b.m呼叫它時要改寫卻不行,因之前xcode更新前執行專案都正常
: 所以小弟實在是不知道問題出在哪邊
: 是否有大大能解救一下愚昧的小弟呢??
: 實在是感激不盡