我有3個UIViews堆疊在另一個上堆疊UITableViews沒有通過觸摸事件視圖下方
的UITableView
的PlaneView
rootView
TableView中在頂部和rootView在底部的頂部上。 (rootView是不可見,因爲TableView中是在它的上面)
我已經實現了下面的代碼在rootView
/*code in rootView*/
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {}
期待的是,這些功能將在最頂部的視圖即TableView中被觸摸或被稱爲移動,但相反,沒有任何功能被調用。
我也試圖把下面的代碼在TableView中,這樣的rootView方法被稱爲
/*code in TableView so that the rootView methods are called(TableView is the subview of rootView)*/
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
[self.superview touchesBegan:touches withEvent:event];
}
正如預期它這樣做,但問題是,TableView中代表像
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
不調用。
有什麼辦法可以確保在TableView類(didSelectRow :)中實現的TableView委託和rootView中的touchesBegan:,touchesMoved ..函數也被相應調用?
ie當我點擊一個TableCell時,兩個(didSelectRow:atIndex)函數在 - > TableView和(touchesBegan和touchesEnd)方法中 - > rootView被調用。
偉大resolution.Thanks的幫助 – prajul
但仍在某個時間點touchesEnded:不叫。我已經做了一些調整touchesEnded:消息的視圖位置,但由於消息不是總是通過視圖調整不按我的預期工作。 – prajul
@prajul:是的,我現在正在摔跤類似的問題。表格視圖是一個非常複雜的野獸。根據你使用的底層觸摸,我嘗試過的另一件事是將一個完全透明的UIView放在我的表格視圖之上。如果你像上面的代碼那樣通過觸摸,表格視圖仍然不能正常工作(你可以點擊它,但不能以任何方式滾動)。但是,如果您通過'hitTest:withEvent:'傳遞,則表視圖將像正常一樣工作,並且您可以在疊加uiview中使用初始hitTest來執行某些操作,如單擊按鈕或其他。 – MusiGenesis