2014-02-19 36 views
-2

我有MPMoviePlayer非常奇怪的問題我花了2天仍然無法找到解決方案。我剛剛將MPMoviePlayer的視圖添加爲self.view的子視圖,但它不響應觸摸方法。但是,當我刪除MPMoviePlayer比視圖響應觸摸方法。我想用MPMoviePlayer觸摸事件。MPMoviePlayer觸摸問題

請幫助...

+0

您可以在MPMoviePlayer中添加點按手勢。 – NiravPatel

+0

我不想用,因爲我對觸摸方法有其他的功能。 –

+0

但你可以給標籤點擊手勢。所以你可以過濾接觸發生時做什麼.. – NiravPatel

回答

0

你可以像下面塞馬

//在movieplayer視圖中添加雙擊手勢...

UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)]; 
[moviePlayer.view addGestureRecognizer:tap]; 

//此方法將被調用時, touch on MPMovieplayer

- (void)handleTap:(UITapGestureRecognizer *)gesture 
{ 
    // Your stuff to increase or decrease the volume. 
} 

讓我知道它工作與否!

快樂編碼!!!!!

+0

我在我的控制器中使用MPMoviePlayer,如果我從視圖觸摸方法的作品中刪除MPMoviePlayer,添加MPMoviePlayer視圖觸摸方法只對MPMoviePlayer有效,MPMoviePlayer幀爲(0,44,320,200),其他視域不響應觸摸方法。 –

+0

你可以通過書寫來觸發其他區域 - (void)touchesBegan:(NSSet *)觸及事件:(UIEvent *)事件方法。 – NiravPatel

0

檢查所有視圖的userInteractionEnabled,並檢查您想要觸摸的方式。如果您使用UIGestureRecognizer,請嘗試將添加識別器添加到MPMoviePlayer視圖的子視圖中。

+0

userInteraction適用於所有視圖。 –