xcode 返回 UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19883728/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]
提问by user2974991
I'm trying to make a free music app and i am trying to put in mp4 video of the music. But the second button just makes it crash with return UIApplicationMain(argc, argv, nil,
NSStringFromClass([AppDelegate class]
The code i'm using is
我正在尝试制作一个免费的音乐应用程序,并且正在尝试放入音乐的 mp4 视频。但是第二个按钮只会让它崩溃 我正在使用的代码是 return UIApplicationMain(argc, argv, nil,
NSStringFromClass([AppDelegate class]
- (IBAction)playButton:(id)sender {
NSString *stringPath = [[NSBundle mainBundle]pathForResource:@"Under_Control" ofType:@"mp3"];
NSURL *url = [NSURL fileURLWithPath:stringPath];
mpc = [[MPMoviePlayerController alloc]initWithContentURL:url];
[mpc setMovieSourceType:MPMovieSourceTypeFile];
[[self view]addSubview:mpc.view];
[mpc setFullscreen:YES];
[mpc play];
- (IBAction)playButton:(id)sender {
NSString *stringPath = [[NSBundle mainBundle]pathForResource:@"Under_Control" ofType:@"mp3"];
NSURL *url = [NSURL fileURLWithPath:stringPath];
mpc = [[MPMoviePlayerController alloc]initWithContentURL:url];
[mpc setMovieSourceType:MPMovieSourceTypeFile];
[[self view]addSubview:mpc.view];
[mpc setFullscreen:YES];
[mpc play];
And also put
而且还放
{
MPMoviePlayerController *mpc;
}
{
MPMoviePlayerController *mpc;
}
Under @interface ViewController;
在下面 @interface ViewController;
回答by Lance
A crash in that location simply means there was an uncaught exception somewhere in your code. Adding an exception breakpoint in Xcode (Exception breakpoints) will make the program crash on the line that is throwing the exception.
该位置的崩溃仅意味着您的代码中某处存在未捕获的异常。在 Xcode 中添加一个异常断点(Exception breakpoints)会使程序在抛出异常的那一行崩溃。
Edit: another thought, are you getting a valid URL variable back? I'm guessing that passing nil
to the MPMoviePlayerController is the problem you are having.
编辑:另一个想法,你得到了一个有效的 URL 变量吗?我猜传递nil
给 MPMoviePlayerController 是您遇到的问题。
回答by DanWebster
If you are using storyboards, check to make sure that you don't have duplicate referencing outlets that you hooked up, or referencing outlets that shouldn't be there anymore that don't have matching methods in your code anymore.
如果您正在使用故事板,请检查以确保您没有重复连接的引用出口,或者引用不应该再存在且代码中不再具有匹配方法的出口。