我有一個NavigationController和其中一個標籤應該加載一個ViewController。ViewController如何知道它專注於iOS?像「viewDidLoad」
這個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視圖)。
謝謝!
我可以設置2個類/ ViewControllers到同一個XIB? – RickON 2013-03-22 23:40:17
你是對的....我開始重新思考我在做什麼.. – RickON 2013-03-23 00:27:59