2010-12-01 174 views
0

所以我有這個UIWindow有一些自定義屬性。我在這個窗口的頂部也有一個透明的UIWebView。現在我已經嵌入了YouTube視頻。問題是當用戶按下視頻時,當Youtube視頻播放時,UIWindow的自定義屬性仍然可見。在iPhone上嵌入Youtube視頻問題

任何人都知道我可以在用戶啓動YouTube視頻時得到通知,並可以在父視圖中隱藏我的自定義設置嗎?

請注意,Youtbe視頻是使用HTML嵌入的。這不是使用原生YouTube.app。

回答

1

我想你可能會缺少一個UIView圖層。就像你的層次結構應該是UIWindow-> UIView-> UIWebView,你的定製應該發生在UIView層上。這可能是你的問題。

什麼自定義屬性保持可見? 您不應該收到應用內youtube播放器出現的通知。它被呈現爲模態視圖控制器。

0

您可以使用這些通知

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

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

}

-(void)removeWebViewPlayNotifications{ 
    [[NSNotificationCenter defaultCenter] 
     removeObserver:self 
     name:UIWindowDidBecomeVisibleNotification 
     object:self.view.window 
     ]; 

    [[NSNotificationCenter defaultCenter] 
    removeObserver:self 
    name:UIWindowDidBecomeHiddenNotification 
    object:self.view.window 
    ]; 

}