我對於由apple提供的MoviePlayer示例代碼有疑問。
我不明白overlayViewTouch通知如何工作。當我觸摸視圖(而不是按鈕)時,我添加到它的NSlog消息不會被髮送。overlayViewTouched通知如何在MoviePlayer示例代碼中工作
// 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通知,如果我把它放在 - (空)的touchesBegan在 「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];
}
}
任何人都可以闡明我失蹤或做錯了什麼?
謝謝。