0

我有一个故事板。在我的 viewDidLoad 中,我可以显示和播放我的电影,但故事板上的任何按钮都被隐藏了。我可以将它们添加到代码中,但更希望将我的图形元素布置在我的故事板上并让它们位于电影的顶部。建议最受赞赏。代码在这里:

- (void)viewDidLoad
{
  [super viewDidLoad];

 // Do any additional setup after loading the view.
  NSString *videoPath = [[NSBundle mainBundle] pathForResource:@"foo" ofType:@"mov"];
  NSURL *url = [NSURL fileURLWithPath:videoPath];

  moviePlayer =  [[MPMoviePlayerController alloc] initWithContentURL:url];

  [[NSNotificationCenter defaultCenter] addObserver:self
                                           selector:@selector(moviePlayBackDidFinish:)
                                               name:MPMoviePlayerPlaybackDidFinishNotification
                                             object:moviePlayer];

  if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
    moviePlayer.view.frame = CGRectMake(0.0f,0.0f,1024.0f,768.0f);
  }

  moviePlayer.controlStyle = MPMovieControlStyleNone;

  [moviePlayer prepareToPlay];

  moviePlayer.repeatMode = MPMovieRepeatModeOne;

  moviePlayer.shouldAutoplay = YES;

  [self.view addSubview:moviePlayer.view];

  [moviePlayer setFullscreen:YES animated:YES];

  [self.moviePlayer play];

  // manually can add buttons here, but prefer not too it in code

  UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
  [myButton addTarget:self
             action:@selector(aMethod:)
   forControlEvents:UIControlEventTouchDown];

  myButton.frame = CGRectMake(26.0, 585.0, 474.0, 87.0);
  myButton.titleLabel.shadowOffset = CGSizeMake(0.0, 0.0);
  [myButton.titleLabel setFont:[UIFont systemFontOfSize:35]];

}
4

1 回答 1

0

解决了。创建了新图层。简单的。

于 2013-04-12T22:57:35.827 回答