我想创建具有披露按钮的表格视图单元格,按下该按钮时将链接到本地视频,但我遇到问题,当我单击披露按钮时屏幕变黑,我正在使用弧。我该怎么办?
这是我的示例代码..我做错了什么
这是我的头文件
#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];
}