I want to add OverlayView to the second movie view in MoviePlayer example. But it does not work. I have the TableView which turns movie play. So I created:
@property (nonatomic, retain) IBOutlet MyOverlayView *overlayView;
in my TableViewController.h like it is in MyMovieViewController.h of the example, and in MyMovieViewController.m which works ok is:
MoviePlayerAppDelegate *appDelegate = (MoviePlayerAppDelegate *)[[UIApplication sharedApplication] delegate];
[appDelegate initAndPlayMovie:[self localMovieURL]];
// now display an overlay window with some controls above the playing movie
NSArray *windows = [[UIApplication sharedApplication] windows];
NSLog(@"\nwindows:\n%@\n", windows);
if ([windows count] > 1)
{
// Locate the movie player window
UIWindow *moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];
[moviePlayerWindow addSubview:self.overlayView];
}
NSLog prints:
windows:
(
<UIWindow: 0x45361b0; frame = (0 0; 320 480); opaque = NO; autoresize = RM+TM; layer = <CALayer: 0x45362b0>>,
<UIEventObservableWindow: 0x4574260; baseClass = UIWindow; frame = (0 0; 320 480); animations = { opacity=<CABasicAnimation: 0x45756f0>; }; layer = <CALayer: 0x45744c0>>
)
but in the same code in TableViewController NSLog prints only:windows:
(
<UIWindow: 0x45361b0; frame = (0 0; 320 480); opaque = NO; autoresize = RM+TM; layer = <CALayer: 0x45362b0>>,
)
And of course if ([windows count] > 1) is false, and it does not work, ehen when I bypass the if condition, and want add the subview to the first element of this table.
Can anyone help me with that? How can I make it work?