Я пытаюсь добавить кнопку в навигационный файл MPMoviePlayerViewController.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];