【发布时间】:2013-12-13 10:47:26
【问题描述】:
我正在尝试使用水平滚动来实现uitableview。我被采取了滚动视图并在滚动视图上添加了表格视图。我设置滚动视图的内容大小大于帧大小。这样它就可以水平滚动。但是当我在 uitableview 上添加滑动手势时,它并没有执行操作。
代码 sn-p 在这里
leftswipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(SwipeRecognizer:)];
leftswipe.delegate = self;
leftswipe.direction = UISwipeGestureRecognizerDirectionLeft;
rightswipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(SwipeRecognizer:)];
rightswipe.delegate = self;
rightswipe.direction = UISwipeGestureRecognizerDirectionRight;
- (void) SwipeRecognizer:(UISwipeGestureRecognizer *)sender
{
if ( sender.direction == UISwipeGestureRecognizerDirectionLeft )
{
NSLog(@" *** SWIPE LEFT ***");
index1++;
self.tableHeaderLabel.text = [self.categoriesLabelArray objectAtIndex:index1];
[self.feedsTableView reloadData];
}
if ( sender.direction == UISwipeGestureRecognizerDirectionRight ){
NSLog(@" *** SWIPE RIGHT ***");
index1--;
self.tableHeaderLabel.text = [self.categoriesLabelArray objectAtIndex:index1];
[self.feedsTableView reloadData];
}
}
我想在向左或向右滑动时重新加载表格。 但目前它不起作用。
【问题讨论】:
-
您想要水平滚动视图和水平滑动手势管理?有冲突是正常的……你应该考虑用两根手指做手势
-
水平滚动视图实现成功但滑动手势未实现
-
您是否在任何视图中添加了左滑和右滑?
-
这和
xcode有什么关系? -
您不需要滑动手势。当 tableViews 框架足够大并且您将 scrollViews contentSize 设置为等于 tableViews 边界时,scrollView 将默认为您提供滚动功能。如果你想要滚动事件管理,使用 scrollViewDelegate 协议
标签: ios objective-c