我有一个 NavigationController,其中一个选项卡应该加载一个 ViewController。
这个 ViewController (1) 在加载到“viewDidLoad”时会做一些事情,然后推送一个新的 ViewController (2)。问题是 ViewController(1) 已经通过 viewDidLoad 之后,它不会再通过它,除非重新启动应用程序。
各位大神能不能给个聪明的办法?
这就是我真正在做的事情:
- (void)viewDidLoad
{
// Keep track of cash using NSUserDefaults
BOOL dreceived[63];
int rightData;
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
//Load cash switches
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSData *data = [prefs objectForKey:@"dreceived"];
memcpy(&dreceived, data.bytes, data.length);
for(int n = 72; n >= 1; n = n - 1)
{
if(dreceived[n-1]==1)
{
rightData = n;
}
}
NSLog(@"Right Data %d", rightData);
CashItem *c = [cashflow objectAtIndex:rightData];
// Go for details
CashDetailedViewController *cdetail = [[[CashDetailedViewController alloc] init] autorelease];
cdetail.cash = c;
cdetail.navigationItem.hidesBackButton = YES;
[self.navigationController pushViewController:cdetail animated:YES];
}
问题是,这段代码再也不会被调用。如果我两次触摸选项卡,则会显示一个空白视图(原始 xib 视图)。
谢谢!