I’m calling a UIAlertView first thing when the app opens and I get the error Applications are expected to have a root view controller at the end of application launch
Any ideas why this would happen
- (void)viewDidLoad
{
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
if([userDefaults stringForKey:@"kUserName"] == nil)
{
NSLog(@"enter a username");
askForUserName = [[UIAlertView alloc] initWithTitle:@"First time here I see!"
message:@"Please enter a username:\n\n"
delegate:self
cancelButtonTitle:@"Done"
otherButtonTitles:nil];
CGRect frame = CGRectMake(48, 70, 200, 20);
usernameField = [[UITextField alloc] initWithFrame:frame];
usernameField.placeholder = @"Username";
usernameField.backgroundColor = [UIColor whiteColor];
usernameField.autocorrectionType = UITextAutocorrectionTypeDefault;
usernameField.keyboardType = UIKeyboardTypeAlphabet;
usernameField.returnKeyType = UIReturnKeyDefault;
usernameField.clearButtonMode = UITextFieldViewModeWhileEditing;
[askForUserName addSubview:usernameField];
[askForUserName show];
} else
{
userName = [userDefaults stringForKey:@"kUserName"];
}
// Do any additional setup after loading the view, typically from a nib.
}
I’ve noticed this happening in an app of mine as well. I think it’s because UIAlertViews block the main thread which trips up the app. I’ve never had any actual issues with this (it doesn’t crash the app or anything), but you could try calling it after a delay with an NSTimer and a block/different thread to remove the warning.