下面的代碼更改標籤名稱,然後選擇索引2問題調用實例方法
[(UITabBarItem*)[self.rootController.tabBar.items objectAtIndex:0] setTitle:@"User"];
self.rootController.selectedIndex = 2;
但是,它的工作原理例如,當應用程序didFinishLaunching方法,但當叫喜歡遵循不工作。
觸摸起來內部按鈕觸發renameTabs:
- (IBAction) renameTabs: (id)sender
{
CompanyAppDelegate *theInstance = [[CompanyAppDelegate alloc] init];
[theInstance rename];
}
和在控制器:
- (void) rename
{
[(UITabBarItem*)[self.rootController.tabBar.items objectAtIndex:0] setTitle:@"User"];
self.rootController.selectedIndex = 2;
}
重命名功能被觸發,並且還在.H定義。沒有錯誤,但沒有改變!有什麼不對的嗎??謝謝
嗨,仍然會崩潰。現在沒有達到重命名,嘗試調用重命名時收到Sigabrt信號。 – Ruth85
你的'CompanyAppDelegate'看起來像這樣:'@interface CompanyAppDelegate:NSObject'?什麼返回'[CompanyAppDelegate sharedAppDelegate];'? –
Nekto
是的,看起來像@interface CompanyAppDelegate:NSObject和[CompanyAppDelegate sharedAppDelegate];在輸出終端上返回0x5b59350和(gbd)。 –
Ruth85