我有一個tableViewController從中導航到UIViewController。爲了保存indexPath.row的值,我使用了一個整數,並基於該整數操作在UIViewController中執行。問題是,當我按下後退按鈕並選擇表的另一個索引時,它導航到UIViewContoller,但執行的操作是第一個。 ViewDidLoad不會再被調用。 這是我的代碼。ViewDidLoad不是第二次調用Xcode
的TableView代碼:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (!self.iaRecipieViewController) {
self.iaRecipieViewController = [[[iRecipieViewController alloc] initWithNibName:@"iRecipieViewController" bundle:nil] autorelease];
}
if (indexPath.row == 0) {
self.iaRecipieViewController.myLableArray =labelSoupArray ;
}
if (indexPath.row == 1) {
self.iaRecipieViewController.myLableArray =labelSoupArray ;
}
if (indexPath.row == 2) {
self.iaRecipieViewController.myLableArray =labelSoupArray ;
}
// custom string is an NSinteger
self.iaRecipieViewController.customString = indexPath.row;
NSLog(@" int %i",self.iaRecipieViewController.customString);
NSLog(@"index path %i ", indexPath.row) ;
[self.navigationController pushViewController:iaRecipieViewController animated:YES];
[detailTable reloadData];
}
UIViewController的代碼。
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
myLabel.text = [self.myLableArray objectAtIndex:customString];
}