2012-10-31 30 views
0

如何修復以下代碼,以便在模擬器中運行應用程序時不發生斷點。 只要我保存並運行應用程序,它說沒有問題,但立即在運行過程後停止並說斷點3.1 4.1錯誤。擺脫/修復斷點3.1和4.1 Xcode iOS 6

#import "XYZViewController.h" 
#import <MediaPlayer/MediaPlayer.h> 


@interface XYZViewController() 


@end 

@implementation XYZViewController 

- (void)viewDidLoad 

{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 

    NSString *movFile = [[NSBundle mainBundle]pathForResource:@"movie1" ofType:@"MP4"]; 


    movPlayer = [[MPMoviePlayerController alloc] initWithContentURL: [NSURL fileURLWithPath:movFile]]; 

    movPlayer.allowsAirPlay=YES; 
    [movPlayer.view setFrame:CGRectMake(0, 0, 320, 480)]; 
    [self.view addSubview:movPlayer.view]; 
    [movPlayer play]; 


} 


- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 


} 

@end 

回答

0

如果您設置了一個斷點或者存在運行時錯誤,則會出現斷點。如果你沒有在那裏設置一箇中斷點,那麼這是一個運行時錯誤。

鑑於您提到3.1 4.1錯誤,這表示運行時錯誤。你應該仔細看看斷點發生的地方,看看有沒有什麼不對。此外,發佈此斷點的位置將有助於他人幫助您。

不知道斷點的位置,我的猜測是,您沒有正確的電影文件名(請記住,iOS區分大小寫),或者movie1.MP4未添加到項目中。

+0

感謝您的回覆。我在哪裏添加movie1.MP4對不起,我是一個新手:( – Nasir

+0

當發生斷點錯誤時,它指向以下內容:[NSURL fileURLWithPath:movFile]]; <---- movFile – Nasir

+0

你可以去文件>將文件添加到「<工作區名稱>」,也可以在右側的Project Navigator中右鍵單擊,或者您可以拖放文件。檢查「將項目複製到目標文件夾組」 – Thomas