3
我想從appDelegate更新其中一個ViewController中的標籤。視圖控制器中的標籤全部在IB中鏈接並具有屬性設置。從appDelegate更新另一個視圖控制器中的標籤
在AppDelegate中.H
我創建的視圖控制器伊娃這樣我就可以在視圖控制器從這樣的委託訪問的標籤。
someViewController *myView;
,並在AppDelegate.m文件
myView.theLabel.text = @"Whatever";
我也試過myView.theLabel setText: @"whatever";
香港專業教育學院還試圖使MyView的一個屬性,它合成。我試過applicationDidFinishLaunching
和applicationWillEnterForeground
中的代碼,但標籤永遠不會更新。什麼是最好的方法來做到這一點?
您是否在您的應用程序委託中實例化控制器,或通過任何其他方式獲取對此控制器實例的引用? – Alladinian
@Alladinian在.h中提到我創建了一個ivar someViewController * myView並以這種方式訪問標籤。 someViewController.h頭文件被添加到appDelegate.h和appDelegate.m中,但不知道你的意思。感謝回覆。 –
@Alladinian對不起我厚厚的不,我沒有從appdelegate實例化視圖控制器我應該做的標籤上面我正在訪問someViewController * myView = [[someViewController alloc] initWithNibName:@「someViewController」等等等等? –