目前我的应用程序有手势,如果你按住UITableView单元格就可以编辑单元格中的对象,如果你点击单元格,你可以在单元格中查看对象。该部分工作得很好但是当用户使用UISearchBar时,结果表没有相同的手势。
我应该在initWithNibName的else部分添加相同的手势吗?
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = NSLocalizedString(@"AutoNotes2", @"AutoNotes2");
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
self.clearsSelectionOnViewWillAppear = NO;
self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);
}
else {
UIImageView *tempImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Concrete.png"]];
[tempImageView setFrame:self.tableView.frame];
self.tableView.backgroundView = tempImageView;
self.searchDisplayController.searchResultsTableView.backgroundView = tempImageView;
}
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleDoubleTap)];
doubleTap.numberOfTapsRequired = 2;
[self.view addGestureRecognizer:doubleTap];
// Two finger, double tap
UITapGestureRecognizer *twoFingerDoubleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTwoFingerDoubleTap:)];
twoFingerDoubleTap.numberOfTapsRequired = 1;
twoFingerDoubleTap.numberOfTouchesRequired = 2;
[self.tableView addGestureRecognizer:twoFingerDoubleTap];
UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
lpgr.minimumPressDuration = 1.0; //seconds
//lpgr.delegate = self;
[self.tableView addGestureRecognizer:lpgr];
}