【问题标题】:Is the Touches works on UITableView and UIScrollView?Touches 是否适用于 UITableView 和 UIScrollView?
【发布时间】:2011-09-08 14:30:38
【问题描述】:

我正在实现一个逐一显示项目列表的应用程序。在那我有一个带有 UITableView 和 UIScrollView 的视图。当我滑动该视图的任何一点时,我需要加载上一个/下一个项目的详细信息。

为此,我使用 TouchBegan 和 TouchEnd 函数来了解我们应该加载什么项目(上一个/下一个)。但是当我在 UITableView 和 UIScrollView 上滑动时,这种滑动不起作用。有什么办法可以使这项工作?请提出建议。

谢谢, 塞卡。

【问题讨论】:

  • 没有看到你的代码——尤其是你的屏幕结构——我只能猜测。可能该事件被不处理触摸的视图捕获。确保所有主要显示的元素都能被触动!

标签: iphone uitableview uiscrollview


【解决方案1】:

此代码可以帮助您使用 Draggable 图像对象创建滚动视图并尝试

@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 {


}

【讨论】:

    【解决方案2】:

    您需要继承 UIScrollView 以使其检测触摸。 UIScrollView 不直接处理触摸。

    查看此链接以了解如何实现。

    Link

    【讨论】:

      猜你喜欢
      • 2015-07-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-25
      • 1970-01-01
      • 1970-01-01
      • 2011-07-02
      相关资源
      最近更新 更多