Button仅在iOS6中隐藏

时间:2013-04-03 07:01:43

标签: iphone ios uibutton mpmovieplayercontroller

在我的应用中,我正在使用MPMoviePlayer播放视频。 我在Movie Player中添加了一个“Skip Ad”(你可以在电影播放器​​的右侧看到)按钮。它在iOS5中工作正常,但是当我在iOS6中运行我的应用程序时,按钮当Movieplayer成为全屏时隐藏。

为什么会发生这种情况......任何想法? 帮助我克服这个......提前谢谢

以下是在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

1 个答案:

答案 0 :(得分:1)

bringSubviewToFront应该可以使用,只需确保您正确使用它。用法是:

[skipButton.superview bringSubviewToFront:skipButton];

如果这不起作用,您可以像这样更改zPosition:

skipButton.layer.zPosition = 1024.0;