2011-12-07 49 views
3

我有UINavigationController,需要在使用storyBoard segue的根UINavigationController後立即顯示。在播放YouTube視頻時按下「完成」按鈕將取消rootViewController

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

這個故事Board segue是Modal。 在此LoginViewController的頂部,我使用代碼段here嵌入了YouTube視頻。

在播放視頻時,按下「完成」按鈕將導致我的LoginViewController與視頻一起被解散。 這也發生在視頻結束時。

有沒有辦法處理「完成」按鈕?有沒有任何通知讓我知道視頻結束的時間?

在此先感謝

回答

1

我發現了一個通知,這讓我知道當視頻結束,但你必須小心使用。 顯然,當youTube視頻播放時,它會出現在UIWindow之上,因此就在您觸發視頻之前註冊UIWindowDidBecomeVisibleNotification通知。像這樣:

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

當視頻結束時,UIWindow會再次出現,並且您應該刪除該通知。

1

添加的UITextField代表你的類,然後設置你的UITextField,以「自我」的委託財產。

處理「完成」(又名「返回」鍵)以下方法:

- (BOOL)textFieldShouldReturn:(UITextField *)theTextField { 
[textField resignFirstResponder]; 
    return NO; 
} 
+0

感謝您的回答。我發佈了我最終使用的調整。 – Amit

相關問題