3

I have UINavigationController which needs to be displayed right after my root UINavigationController using storyBoard segue.

[self performSegueWithIdentifier:@"LoginViewController" sender:self];

This storyBoard segue is Modal. On top of this LoginViewController I embedded YouTube video using the snippet here.

While the video is playing, pressing on the "Done" button will cause my LoginViewController to be dismissed along with the video. It also happens when the video ends.

Is there any way to handle the "Done" button? is there any notification which Let me know when the video ends?

Thanks in advance

Community
  • 1
  • 1
Amit
  • 205
  • 4
  • 8

2 Answers2

1

Add the UITextfield Delegate to your class, then set the delegate property of your uitextfield to "self".

Handle the "done" (aka "return") key with the following method:

- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {
[textField resignFirstResponder];
    return NO;
}
PRNDL Dev
  • 55
  • 1
  • 7
1

I found a notification which helped me to know when the video end but you will have to use it carefully. Apparently, When the youTube video plays, it appears on top of the UIWindow, So just before you trigger your video register the UIWindowDidBecomeVisibleNotification notification. Like this:

   [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowNowVisible:)
         name:UIWindowDidBecomeVisibleNotification
         object:self.view.window
         ];

When the video ends, The UIWindow comes visible again and and there you should remove the notification.

Amit
  • 205
  • 4
  • 8