0
從堆棧中的視圖調用下面的代碼之前或之後我想在程序將彈出的根視圖上設置標籤的文本。如何在根視圖控制器上設置標籤的文本
[self.navigationController popViewControllerAnimated:YES];
我能做到這一點的其他方式(如下)推視圖控制器到堆棧的時候,但我不知道如何做到這一點從堆棧彈出
- (PushedViewController *) pushedViewController {
NSLog(@"Initialise view");
if (pushedViewController == nil) {
pushedViewController = [[PushedViewController alloc] initWithNibName:@"PushedView" bundle:nil];
}
return pushedViewController;
}
#pragma mark -
#pragma mark Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[TableView deselectRowAtIndexPath:indexPath animated:YES];
Table* tableRow =[fetchedResultsController objectAtIndexPath:indexPath];
[self.navigationController pushViewController:self.pushedViewController animated:YES];
self.pushedViewController.code.text = tablerow.code;
}
時如果有人能告訴我如何在堆棧中訪問和設置視圖的變量而不創建視圖的新實例,那將是值得讚賞的。
'[[[navigationController rootViewController] textLabel] setText:@「Foo」];' – 2012-08-12 08:17:55
@ H2CO3當我這樣做,我得到錯誤「沒有已知的選擇器rootViewController的類方法」也將允許我設置文本一個文本框? – msec 2012-08-12 08:28:49
對不起,我的意思是說方法名稱爲topViewController。 – 2012-08-12 08:36:01