对不起,如果标题似乎有点模棱两可。
我正在从viewDidLayoutSubviews
我的类的方法中调用一个函数 checkLogin。这是该方法的代码:
KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:@"UserLogin" accessGroup:nil];
NSString *activeUser = [keychain objectForKey:(id)kSecAttrAccount];
int length = [activeUser length];
NSLog(@"%d", length);
if (length > 0) {
NSLog(@"Greater than 0");
[testLabel setHidden:FALSE];
[testLabel setText:@"Currently logged in"];
/*
To fix this, create a new button?
*/
[loginButton setTitle:@"Log Out" forState:UIControlStateNormal];
} else {
NSLog(@"Less than 0");
[testLabel setHidden:TRUE];
[loginButton setTitle:@"Log In" forState:UIControlStateNormal];
//[loginButton setTitle:@"Log In" forState:UIControlStateHighlighted];
}
// Logout [keychain resetKeychainItem];
每当我试图更改文本的标题时,我的程序就会崩溃,我不明白为什么。谁能帮我解决这个问题?
我得到的错误是
*** Assertion failure in -[UIView layoutSublayersOfLayer:], /SourceCache/UIKit/UIKit-2380.17/UIView.m:5781\ 2013-03-20 16:24:55.751 CompAir[5321:907] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after sending -viewDidLayoutSubviews to the view controller. FirstViewController's implementation needs to send
-layoutSubviews to the view to invoke auto layout.'}