2013-04-03 80 views
0

在我的應用程序中,我使用MPMoviePlayer播放視頻。 我在電影播放器​​上添加了一個「跳過廣告」(您可以在電影播放器​​的右側看到)按鈕。它在iOS5中工作正常,但是當我在iOS6中運行我的應用程序時,該按鈕在Movieplayer變成全屏。按鈕只在iOS6中隱藏

爲什麼會發生這種情況......任何想法? 幫助我克服this..thanks提前

下面是用於添加MPMovieplayer按鈕的代碼,以及屏幕截圖

UIButton *skipButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
skipButton.frame = CGRectMake(264.0,195.0, 67.0, 25.0); 
[skipButton setTitle:@"" forState:UIControlStateNormal]; 
skipButton.backgroundColor = [UIColor clearColor]; 
[skipButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal ]; 
UIImage *buttonImageNormal3 = [UIImage imageNamed:@"skipad.png"]; 
UIImage *strechableButtonImageNormal3 = [buttonImageNormal3 stretchableImageWithLeftCapWidth:12 topCapHeight:0]; 
[skipButton setBackgroundImage:strechableButtonImageNormal3 forState:UIControlStateNormal]; 
UIImage *buttonImagePressed3 = [UIImage imageNamed:@"skipad.png"]; 
UIImage *strechableButtonImagePressed3 = [buttonImagePressed3 stretchableImageWithLeftCapWidth:12 topCapHeight:0]; 
[skipButton setBackgroundImage:strechableButtonImagePressed3 forState:UIControlStateHighlighted]; 
[skipButton addTarget:self action:@selector(skipAction:) forControlEvents:UIControlEventTouchUpInside]; 



[[[UIApplication sharedApplication] keyWindow] addSubview:skipButton]; 

在iOS5中 -

iOS5 - before fullscreen

iOS5 - after fullscreen

在iOS6的 -

iOS6 - before fullscreen

iOS6 - after fullscreen

+0

你爲什麼不添加按鈕,電影播放器​​的[圖](HTTP:// developer.apple.com/library/ios/documentation/MediaPlayer/Reference/MPMoviePlayerController_Class/Reference/Reference.html#//apple_ref/occ/instp/MPMoviePlayerController/view)而不是主窗口? –

+0

你可以指定如何添加像? – user2115266

+0

與somethig像:[self.view addSubview:skipButton];我猜:) – Lucabro

回答

1

bringSubviewToFront應該工作,只要確保你正確地使用它。用法:

[skipButton.superview bringSubviewToFront:skipButton]; 

如果不工作,你可以改變z位置,像這樣:

skipButton.layer.zPosition = 1024.0;