0

押されたときにローカルビデオにリンクする開示ボタンを持つテーブルビューセルを作成したいのですが、開示ボタンをクリックすると画面が真っ暗になり、アークを使用しています。これについてどうすればいいですか?

これが私のサンプルコードです..何が間違っていますか

ここに私のヘッダーファイルがあります

 #import <UIKit/UIKit.h>
  #import <MediaPlayer/MediaPlayer.h>

 @interface BIDVideosViewController : UIViewController

 <UITableViewDelegate, UITableViewDataSource>

 @property (nonatomic,strong) NSArray *tableList;

 @end

ここに私の.mファイルがあります

 #import "BIDVideosViewController.h"

 @interface BIDVideosViewController ()
 {
 MPMoviePlayerController *moviePlayer;

 }

 @end

 @implementation BIDVideosViewController

 @synthesize tableList;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
 {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
 }
 return self;
 }

- (void)viewDidLoad
{
[super viewDidLoad];
UITableView *table = [[UITableView alloc]initWithFrame:self.view.bounds];
[table setDelegate:self];
[table setDataSource:self];
[self.view addSubview:table];
 NSArray *array = [[NSArray alloc] initWithObjects:@"Gangan",@"SwimGood", nil];
self.tableList = array;
 // Do any additional setup after loading the view.
}

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

 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
 {
  return [tableList count];
  }
 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
   {
 static NSString *DisclosureButtonIdentifier = @"DisclosurebutotonIdentifier";
  UITableViewCell *cell = [tableView       dequeueReusableCellWithIdentifier:DisclosureButtonIdentifier];
  if (cell == nil)
  {
   cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault       reuseIdentifier:DisclosureButtonIdentifier];
   }
  NSInteger row = [indexPath row];
   NSString *rowString = [tableList objectAtIndex:row];
  cell.textLabel.text = rowString;
  cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
  return cell;
  }

  -(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:   (NSIndexPath *)indexPath
  {
  NSString *thePath = [[NSBundle mainBundle] pathForResource:@"Gangan" ofType:@"mp4"];
  NSLog(@"path is ...%@", thePath);
  NSURL *theurl = [NSURL fileURLWithPath:thePath];
  MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:theurl];
  [moviePlayer.view setFrame:CGRectMake(0, 0, 320, 460)];
  [self.view addSubview:moviePlayer.view];
  [moviePlayer prepareToPlay];
  [moviePlayer play]; 

}

4

2 に答える 2

3

numberOfSectionsInTableView:UITableView または必要なtableView:numberOfRowsInSection:メソッドがありません。

追加してみる

UITableView *table = [[UITableView alloc] initWithFrame:self.view.bounds];
[table setDelegate:self];
[table setDataSource:self];
[self.view addSubview:table];

あなたのviewDidLoad機能に。

UITableView を適切に実装するために必要なメソッド (および使用可能なメソッド) については、デリゲートデータ ソースのドキュメントを参照してください。すべて (描画とセットアップ) を処理してくれるので、この方法は便利です。値を指定するだけで、データのロード時に自動的に描画されます。

于 2012-10-15T19:23:04.450 に答える
1

あなたはこのように試すことができます

NSString *thePath=[[NSBundle mainBundle] pathForResource:@"animation" ofType:@"mov"];
NSLog(@" path is...%@",thePath);
NSURL *theurl=[NSURL fileURLWithPath:thePath];

MPMoviePlayerController *moviePlayer =[[MPMoviePlayerController alloc] initWithContentURL:theurl];

[moviePlayer.view setFrame:CGRectMake(0, 0, 320, 460)];  
[self.view addSubview: moviePlayer.view];
//[moviePlayer setFullscreen:YES animated:NO];
[moviePlayer prepareToPlay];
[moviePlayer play];

それは私のために働いた、あなたのためにも働くことを願っています

于 2012-10-16T11:39:12.550 に答える