[英]UISwipeGestureRecognizer in viewForHeaderInSection
我正在嘗試僅向表標題添加向左滑動識別。 似乎不起作用-嘗試了在stackoverflow和Web上找到的所有內容。 在實際的表格單元格上工作正常,但是將其添加到表格標題時……什么也沒有。
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{SnapSong * song = nil;
NSString *文本= song.title; NSString * detailedText = song.albumName;
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 80)];
view.backgroundColor = [[Globals sharedInstance] gCellBgColor];
view.tag = section;
UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self
action:@selector(handleSwipeLeft:)];
[recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[view addGestureRecognizer:recognizer];
return view;
}
它只是不會滑動,我嘗試過在桌子上添加手勢等。
謝謝您的幫助
好吧,讓這個變戲法的東西起作用了
UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self
action:@selector(handleSwipeLeft:)];
**[recognizer setDelegate:self];**
[recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
[view addGestureRecognizer:recognizer];
並且必須添加2個功能:
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{返回是; }
當然,在.h文件中添加委托
@interface TableViewController : UIViewController<UIGestureRecognizerDelegate>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.