Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4254658
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:06:50+00:00 2026-05-21T05:06:50+00:00

4 files for 2 view controllers, firstviewcontroller and MyOverlayView. MyOverlayView just receives touches and

  • 0

4 files for 2 view controllers, firstviewcontroller and MyOverlayView. MyOverlayView just receives touches and sends notification which should be received by firstviewcontroller. Im getting touch event on the overlayview but not receiving the notification at firstviewcontroller. Any ideas?

FVC-Header

#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

FVC-Implementation

#import "FirstViewController.h"
#import "SMWebRequest.h"

NSString * const OverlayViewTouchNotification = @"overlayViewTouch";

@implementation FirstViewController
@synthesize mvc;
@synthesize overlayView;
@synthesize keyArray, urlDic;

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    [super viewDidLoad];
}

-(void)viewDidAppear:(BOOL)animated
{
    [self loadArray];
    if (!overlayView) {
        overlayView = [[MyOverlayView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    }
    NSArray *windows = [[UIApplication sharedApplication] windows];
    if ([windows count] >= 1)
    {
        // Locate the movie player window
        UIWindow *moviePlayerWindow = [[UIApplication sharedApplication] keyWindow];
        // Add our overlay view to the movie player's subviews so it is 
        // displayed above it.
        [moviePlayerWindow addSubview:self.overlayView];
    }

    //[self.parentViewController.view addSubview:overlayView];
}

-(void)loadArray{
    if (!urlDic) {
        NSMutableDictionary *tempDic = [NSMutableDictionary new];
        [tempDic setObject:@"mp4" forKey:@"euromount_high_res"];

        urlDic = [[NSDictionary alloc] initWithDictionary:tempDic];
    }

    if (!keyArray) {
        NSArray *tempArray = [urlDic allKeys];
        keyArray = [[NSArray alloc] initWithArray:tempArray];
    }
    //Random choice
    int point = rand() % ([keyArray count]);
    //Call play movie
    [self playMovieAtURL :urlDic :keyArray :point];
}

-(void)playMovieAtURL:(NSDictionary *)dic:(NSArray *)array:(int)rand
{   
    NSString *key = [array objectAtIndex:rand];
    NSString *path = [[NSBundle mainBundle] pathForResource:key ofType:[dic valueForKey:key]];


    if (mvc == nil) { mvc = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:path]]; }

    mvc.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
    mvc.moviePlayer.shouldAutoplay = TRUE;
    mvc.moviePlayer.controlStyle = MPMovieControlStyleNone;

    // Register for the playback finished notification.
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(myMovieFinishedCallback:)
                                                 name:MPMoviePlayerPlaybackDidFinishNotification
                                               object:nil];

    [self presentModalViewController:mvc animated:YES];

    // Movie playback is asynchronous, so this method returns immediately. 
    [mvc.moviePlayer play];
} 

// When the movie is done,release the controller. 
-(void)myMovieFinishedCallback:(NSNotification*)aNotification 
{
    [[NSNotificationCenter defaultCenter] removeObserver:self 
                                                    name:MPMoviePlayerPlaybackDidFinishNotification 
                                                  object:nil]; 
    //for (UIView *view in self.view.subviews) {
    //    [view removeFromSuperview];
    //}
    mvc = nil;
    [self loadArray];
}

// Touches in the overlay view (not in the overlay button)
// post the "overlayViewTouch" notification and will send
// the overlayViewTouches: message
- (void)overlayViewTouches:(NSNotification *)notification
{
    NSLog(@"screen touched");
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return YES;
}


- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc. that aren't in use.
}


- (void)viewDidUnload
{
    mvc = nil;
    keyArray = nil;
    urlDic = nil;
    [super viewDidUnload];
}

-(void)reset{
    for (UIView *view in self.view.subviews) {
        [view removeFromSuperview];
    }
    mvc = nil;
    keyArray = nil;
    urlDic = nil;
    [self loadArray];
}

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

@end

MyOverlayView-Header

#import <UIKit/UIKit.h>


@interface MyOverlayView : UIView {
}

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

@end

MyOverlayView-Implementation

#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

****EDIT ANSWER*******
I wasnt adding an observer for the notification. Got it all sorted out.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T05:06:51+00:00Added an answer on May 21, 2026 at 5:06 am

    I wasn’t adding an observer for the notification. Got it all Sorted out

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have quite a lot of PHP view files, which I used to include
I am developing a web application with which user can view files in the
Lets say that I have 4 view controllers (call them FirstView,SecondView,ThirdView,FourthView) which are created
I have multiple .xib files and multiple view controllers. Problem is when I pass
I have two view controllers named view1ViewController and view2ViewController in an cocoa touch project,
lets say i have two view controllers, firstViewController and secondViewController. The firstViewController is supposed
I'm looking for a tool to browse and view files stored within a Team
I can't seem to find/view .htaccess files in Eclipse PDT. I looked in the
In objective c (iphone) are the nib files (xib) the View part of the
I am trying to insert JS files into the view but they are being

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.