Objective c 触摸覆盖

Objective c 触摸覆盖,objective-c,mpmovieplayercontroller,nsnotificationcenter,Objective C,Mpmovieplayercontroller,Nsnotificationcenter,4个文件,用于2个视图控制器,firstviewcontroller和MyOverlayView。MyOverlayView只接收触摸并发送应由firstviewcontroller接收的通知。我在overlayview上收到触摸事件,但在firstviewcontroller上未收到通知。有什么想法吗 FVC头 #import <UIKit/UIKit.h> #import <MediaPlayer/MediaPlayer.h> #import "MyOverlayVi

4个文件,用于2个视图控制器,firstviewcontroller和MyOverlayView。MyOverlayView只接收触摸并发送应由firstviewcontroller接收的通知。我在overlayview上收到触摸事件,但在firstviewcontroller上未收到通知。有什么想法吗

FVC头

#import <UIKit/UIKit.h>
#import <MediaPlayer/MediaPlayer.h>
#import "MyOverlayView.h"

extern NSString *const OverlayViewTouchNotification;

@interface FirstViewController : UIViewController {
    MPMoviePlayerViewController *mvc;
    MyOverlayView *overlayView;
    NSArray *keyArray;
    NSMutableDictionary *urlDic;
}

@property (nonatomic, retain) MPMoviePlayerViewController *mvc;
@property (nonatomic, retain) IBOutlet MyOverlayView *overlayView;
@property (nonatomic, retain) NSArray *keyArray;
@property (nonatomic, retain) NSMutableDictionary *urlDic;

-(void)playMovieAtURL:(NSDictionary *)dic:(NSArray *)array:(int) rand;
-(void)overlayViewTouches:(NSNotification *)notification;
-(void)loadArray;
-(void)reset;
@end
MyOverlayView标题

#import <UIKit/UIKit.h>


@interface MyOverlayView : UIView {
}

- (void)awakeFromNib;
- (void)dealloc;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;

@end
******编辑答案*********
我没有为通知添加观察员。一切都搞定了。

我没有为通知添加观察员。都搞定了

#import <UIKit/UIKit.h>


@interface MyOverlayView : UIView {
}

- (void)awakeFromNib;
- (void)dealloc;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;

@end
#import "MyOverlayView.h"
#import "FirstViewController.h"

@implementation MyOverlayView

// MPMoviePlayerController will play movies full-screen in 
// landscape mode, so we must rotate MyOverlayView 90 degrees and 
// translate it to the center of the screen so when it draws
// on top of the playing movie it will display in landscape 
// mode to match the movie player orientation.
//
- (void)awakeFromNib
{
    CGAffineTransform transform = self.transform;

    // Rotate the view 90 degrees. 
    transform = CGAffineTransformRotate(transform, (M_PI / 2.0));

    UIScreen *screen = [UIScreen mainScreen];
    // Translate the view to the center of the screen
    transform = CGAffineTransformTranslate(transform, 
        ((screen.bounds.size.height) - (self.bounds.size.height))/2, 
        0);
    self.transform = transform;

    CGRect newFrame = self.frame;
    newFrame.origin.x = 190;
    self.frame = newFrame;
}

- (void)dealloc {
    [super dealloc];
}

// Handle any touches to the overlay view
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch* touch = [touches anyObject];
    if (touch.phase == UITouchPhaseBegan)
    {
        NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
        [nc postNotificationName:OverlayViewTouchNotification object:nil];
    }    
}


@end