Xcode Objective-C Mac: How to place object on top of AVPlayerView?

306 views Asked by At

I'm currently working on a game. It plays a movie and the story changes depending on the players actions. I'm using quick time events (press a button in x seconds). When there's a quick time event I want to show the button that has to be pressed and the time left to press that button.

I play the movie(s) using an AVPlayerView. On top of that AVPlayerView I have placed a label. But the label is always invisible. It's because of the AVPlayerView.

So does anyone know a way around this?

Edit

I didn't use any code to place the label on top of the AVPlayerView. I just placed it there in the MainMenu.xib. When I view it in Xcode it looks like this:

Screenshot in Xcode

But when I run the application it looks like this:

Screenshot in Xcode

As you can see in the first image, all objects are under "View" and the label appears lower in the list so it should be on top of the AVPlayerView. Xcode displays the label on top of the AVPlayerView (image 1), but when I run the application the label is underneath the AVPlayerView (image 2). So my question was how to display the label on top of the AVPlayerView.

I hope this is enough information ;)

1

There are 1 answers

0
Andrea Vultaggio On

Link your label to an IBOutlet in the ViewController which describes your view and in the viewDidLoad() method write

/*top of your file*/
@property (strong, nonatomic) IBOutlet UILabel *myLabel;
/* other properties */

@implementation MyViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    /*code*/

    [self.view bringSubviewToFront:myLabel]; 
}

/*rest of your code*/

This should do the trick for you.