2011-09-08 58 views
0

我正在實現一個逐一顯示項目列表的應用程序。在那裏我有一個與UITableView和UIScrollView視圖。當我滑動該視圖的任何點時,我需要加載上一個/下一個項目的詳細信息。Touches在UITableView和UIScrollView上工作嗎?

對於這個我是TouchBegan和TouchEnd函數來知道我們應該加載什麼項目(上一個/下一個)。但是當我在UITableView和UIScrollView上滑動時,此刷卡不起作用。有什麼辦法可以做到這一點?請建議。

謝謝, Sekhar。

+0

沒有看到你的代碼 - ESP的屏幕結構 - 我只能猜測。可能該事件被不能處理觸摸的視圖所捕獲。確保所有顯示的主要元素都能捕捉到觸摸! – user387184

回答

0

您需要繼承UIScrollView以使其檢測觸摸。 UIScrollView不直接處理觸摸。

看看這個鏈接,知道如何實現這一點。

Link

1

這段代碼可以幫助您創建滾動型與可拖動圖像對象,並嘗試

@interface DraggableImages : UIScrollView { 


} 


@implementation DraggableImages 
@synthesize delegate; 
- (id)initWithFrame:(CGRect)frame { 


    self = [super initWithFrame:frame]; 

     return self; 
} 


//called when we touch the box 
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event { 
    // Retrieve the touch point 


} 
//called when we move box 

- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event { 

} 
//called when touch is cancelled 
-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event 
{ 

} 

//called when touch is ended 
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 


}