我有一個名爲DebugViewController的UIViewController,它包含一個UITextView和一個名爲debugPrint的公共方法,它用於將NSString寫入UITextView並顯示它。在視圖加載之前使用視圖控制器方法的幫助
是否可以在打開UIViewController之前寫入UITextView,以便當我打開它時,先前寫入它的文本被顯示出來?
在我父視圖控制器viewDidLoad方法,我在DebugViewController調用initWithNibName如下
debugViewController = [[DebugViewController alloc] initWithNibName:@"DebugView" bundle:nil];
然後我打電話debugPrint如下
[debugViewController debugPrint:@"viewDidLoad"];
一段時間後,我撥打以下打開debugViewController
debugViewController.delegate = self;
debugViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:debugViewController animated:YES];
但是之前編寫的所有文本都丟失了。
請讓我知道如何在視圖控制器顯示給用戶之前使用視圖控制器方法。
感謝,
JustinP
大概你的textview沒有被初始化,這是因爲從nib的清醒還沒有被調用.. – Daniel
謝謝丹尼爾,是否有可能強制喚醒呼叫? – JustinP