我正在尝试在 MPMoviePlayerViewController 的 navigationcontroller.view 上添加按钮。到目前为止,我已经写了以下内容。它没有给出任何错误,但按钮没有出现在视图中!谁能告诉我我做错了什么?谢谢。
MPMoviePlayerViewController *videoController = [[[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL URLWithString:filePath]] autorelease];
UIButton *favButton = [UIButton buttonWithType:UIButtonTypeCustom];
favButton.frame = CGRectMake(280, 25, 30, 30);
[favButton addTarget:self action:@selector(favouriteButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
[favButton setBackgroundImage:[UIImage imageNamed:@"unselected.png"] forState:UIControlStateNormal];
[videoController.navigationController.view addSubview:favButton];
[self presentMoviePlayerViewControllerAnimated:videoController];
- (void)favouriteButtonClicked:(id)sender
{
NSLog(@"Inside favourite button clicked");
}
也尝试使用以下代码添加,但没有运气!
UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(favouriteButtonClicked:)];
videoController.navigationController.navigationItem.rightBarButtonItem=button;
[button release];