これで、前回のコードを正しく投稿できませんでした...私は初心者です。私は少し変更して、私はuiTableViewから再生するビデオを取得しようとしています。私はクラッシュすることはありません、私はちょうど約20秒間黒い画面を取得し、シミュレータまたはiPhoneは、uiTableViewに戻ります。 「オプション1」を選択すると、警告が表示されます。私は、iOS 4.0用に開発したXcode 4.2を使用しています。まだ私のアプリでビデオを再生しようとしています
私は2,3日間頭を叩いていて、何か助けに感謝しています。
はここに私の.h
#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
@interface faq2 : UITableViewController
{
NSArray *faqList;
}
@property (nonatomic, strong) NSArray *faqList;
-(IBAction)playMovie;
@end
であることはここで私は私がproplerlyフレームワークを追加しましたかなり確信している私の.m
-(IBAction)playMovie
{
NSString *filepath = [[NSBundle mainBundle] pathForResource:@"WhatFinalTake" ofType:@"mp4"];
NSURL *fileURL = [NSURL fileURLWithPath:filepath];
MPMoviePlayerController *moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackComplete:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayerController];
[self.view addSubview:moviePlayerController.view];
moviePlayerController.fullscreen = YES;
[moviePlayerController play];
}
- (void)moviePlaybackComplete:(NSNotification *)notification
{
MPMoviePlayerController *moviePlayerController = [notification object];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:moviePlayerController];
[moviePlayerController.view removeFromSuperview];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.faqList = [[NSArray alloc] initWithObjects:
@"Play Movie",
@"Option 1", nil];
self.title = @"Frequently Asked Questions";
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
self.faqList = nil;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [faqList count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// Configure the cell.
cell.textLabel.text = [self.faqList objectAtIndex: [indexPath row]];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row == 0)
{
[self playMovie];
}
else if (indexPath.row == 1)
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Option 1" message:@"Option 1" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil, nil];
[alert show];
}
}
ですが、JIKはここにスクリーンショットです。
ログにエラーメッセージがありますか? –
は20秒ほどのビデオですか?黒い画面が実際にあなたのビデオである可能性があります –
私のログを確認する方法はわかりません。私のビデオは約2分です。ログでエラーをチェックするにはどうすればよいですか? – sdknewbie