У меня есть вопрос относительно MoviePlayer примера кода, предоставленного Apple.
Я не понимаю, как работает уведомление overlayViewTouch. Добавленное к нему сообщение NSlog не отправляется, когда я касаюсь представления (не кнопки).
// post the "overlayViewTouch" notification and will send
// the overlayViewTouches: message
- (void)overlayViewTouches:(NSNotification *)notification
{
NSLog(@"overlay view touched");
// Handle touches to the overlay view (MyOverlayView) here...
}
Я могу, однако, получить уведомление NSlog, если я помещу его в - (void) touchSegan в "MyOverlayView.m" Что заставляет меня думать, что распознает прикосновения, но не отправляет уведомление.
// Handle any touches to the overlay view
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch* touch = [touches anyObject];
if (touch.phase == UITouchPhaseBegan)
{
NSLog(@"overlay touched(from touchesBegan")
// IMPORTANT:
// Touches to the overlay view are being handled using
// two different techniques as described here:
//
// 1. Touches to the overlay view (not in the button)
//
// On touches to the view we will post a notification
// "overlayViewTouch". MyMovieViewController is registered
// as an observer for this notification, and the
// overlayViewTouches: method in MyMovieViewController
// will be called.
//
// 2. Touches to the button
//
// Touches to the button in this same view will
// trigger the MyMovieViewController overlayViewButtonPress:
// action method instead.
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc postNotificationName:OverlayViewTouchNotification object:nil];
}
}
Может ли кто-нибудь пролить свет на то, что я упускаю или делаю неправильно?
Спасибо.