iPhone App Splash Screen Crashes when trying to load
I am writing an app that allows the user to snap a photo with the camera or choose a photo from library and once a picture is selected, the user is taken to another view where he can see a "rating" of his photo and share it to Facebook/Twitter etc. However, before showing the rating of the picture, I want to show a loading screen with the spinning wheel inside it. For some reason, when I add to "viewDidLoad" [sel开发者_StackOverflow社区f showSplash], it gives the SIGABRT error.
This is my code for showing the splash screen. The error is on the second line of the showSplash method. (or at least that's where it crashes)
-(void) showSplash{
UIViewController *modalViewController = [[UIView alloc] init];
[modalViewController setView:splash];
[self presentModalViewController:modalViewController animated:NO];
[self performSelector:@selector(hideSplash) withObject: nil afterDelay:0.5];
}
-(void) hideSplash{
[[self modalViewController] dismissModalViewControllerAnimated:YES];
}
Can anyone please tell me why it crashes? Thanks!
You're allocing a UIView
not a UIViewController
, try this:
UIViewController *modalViewController = [[UIViewController alloc] init];
In the first line of showSplash
change UIView
to UIViewController
.
What does the error say after SIGABRT? There should be some helpful text printed out with the crash.
精彩评论