MPMoviePlayerViewController

MPMoviePlayerViewController

本文介绍了iPhone:MPMoviePlayerViewController导航栏上的“添加"按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在MPMoviePlayerViewController的navigationcontroller.view上添加按钮.到目前为止,我已经写了以下内容.它没有给出任何错误,但是按钮没有出现在视图中!有人可以告诉我我在做什么错吗?谢谢.

I am trying to add button on MPMoviePlayerViewController's navigationcontroller.view. I have wrote following so far. It doesn't give any error but button isn't appearing on view! Could anyone please tell me what am I doing wrong? Thanks.

        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");
}

也请尝试使用以下代码添加内容,但是没有运气!

Also try adding using following code but no luck!

        UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(favouriteButtonClicked:)];
        videoController.navigationController.navigationItem.rightBarButtonItem=button;
        [button release];

推荐答案

UIBarButtonItem *button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(favouriteButtonClicked:)];
videoController.navigationItem.rightBarButtonItem = button;
[button release];

这篇关于iPhone:MPMoviePlayerViewController导航栏上的“添加"按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-11 13:25