如何在iphone中使用后退按钮更改变量的值
当选择默认的后退按钮时,我需要更改上一个视图变量的值。如何在iphone应用程序中使用ViewController开发此功能 我试图通过创建一个自定义的后退按钮和set方法来实现这一点。我在viewwilldiscover方法中调用这两个方法如何在iphone中使用后退按钮更改变量的值,iphone,variables,uiviewcontroller,uibutton,Iphone,Variables,Uiviewcontroller,Uibutton,当选择默认的后退按钮时,我需要更改上一个视图变量的值。如何在iphone应用程序中使用ViewController开发此功能 我试图通过创建一个自定义的后退按钮和set方法来实现这一点。我在viewwilldiscover方法中调用这两个方法 -(void)viewWillDisappear:(BOOL)animated{ // Initialize next table view controller and set data to that view. FTTestSumma
-(void)viewWillDisappear:(BOOL)animated{
// Initialize next table view controller and set data to that view.
FTTestSummaryTableViewController *testSummaryViewController =
[[FTTestSummaryTableViewController alloc]
initWithNibName:@"FTTestSummaryTableViewController" bundle:nil];
[testSummaryViewController setCurrentIndex:self.currentIndex];
}
我无法使用这些方法将当前索引值从现有视图传递到上一个视图。当我转到上一个视图时,它总是显示最后一个currentIndex值,而不是使用setCurrentIndex设置的值
我的代码有什么问题,或者是否有其他方法可以实现这一点 尝试在“第二”视图中引用“第一”视图 FirstViewController.m SecondViewController.h SecondViewController.m
你能格式化你的代码吗?
SecondViewController *second = [SecondViewController alloc] init...];
second.first = self;
[self.navigationController pushViewController:second animated:YES];
FirstViewController *first;
@property(nonatomic, retain) FirstViewController *first;
- (void) viewWillDissappear
{
self.first.some_property = @"something";
}