我有一个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];
}