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

  • Home
  • SEARCH
  • 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 5839961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:40:04+00:00 2026-05-22T11:40:04+00:00

I have a view with a web view which loads a YouTube video. I

  • 0

I have a view with a web view which loads a YouTube video. I am using the following methods to automatically start the YouTube video when the web view is loaded.

The web view opens the iPhones native movie player. Is there any way to check if the video has ended or the user has pushed the “OK” button of the movie player and the player is thereby closed?

These are the methods I use for automatically starting the web view:

- (UIButton *)findButtonInView:(UIView *)view {
    UIButton *button = nil;

    if([view isMemberOfClass:[UIButton class]]) {
        return (UIButton *)view;
    }

    if(view.subviews && [view.subviews count] > 0) {
        for(UIView *subview in view.subviews) {
            button = [self findButtonInView:subview];
            if(button) return button;
        }
    }

    return button;
}

- (void)webViewDidFinishLoad:(UIWebView *)_webView {
    UIButton *b = [self findButtonInView:_webView];
    [b sendActionsForControlEvents:UIControlEventTouchUpInside];
}
  • 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-22T11:40:05+00:00Added an answer on May 22, 2026 at 11:40 am

    Apple doesn’t push a [documented] notification for this, so you have to get a little tricky.

    The way I do it is to check the application’s keyWindow. I got the idea from here.

    in your .h file, keep track of your timer and the desired keyWindow:

    NSTimer *windowTimer;
    UIWindow *keyWindow;
    

    in your .m file, you need the following:

    - (void)viewDidLoad {
        [super viewDidUnload];
        keyWindow = [[UIApplication sharedApplication] keyWindow];
    }
    

    Then Edit your delegate method and add one new method:

    - (void)webViewDidFinishLoad:(UIWebView *)_webView {
        UIButton *b = [self findButtonInView:_webView];
        [b sendActionsForControlEvents:UIControlEventTouchUpInside];
    
        // start checking the current keyWindow
        windowTimer = [NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(checkWindowStatus) userInfo:nil repeats:YES];
    }
    
    - (void) checkWindowStatus {
        // if the key window is back to our application
        if (keyWindow == [[UIApplication sharedApplication] keyWindow]) {
            [windowTimer invalidate];
            windowTimer = nil;
    
            ... window has dismissed, do your thing ...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have a abstract view for any type of UI (web or
In a VS2008 web site project, I have a page open in split view.
I have a view using a master page that contains some javascript that needs
I have a view which contains a form, the form posts and the data
I have a View class (OrderView.aspx) which shows the details of an order (Account
Hey all... I have a view controller (A) which on some action, alloc init's
I have a web solution (in VS2010) with two sub-projects: Domain which holds the
I have an Android app which I use to register users on my web
I have a view that has a list of jobs in it, with data
I have a view user control that can post form. This control can be

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.