uitableviewCell必须长按

时间:2014-08-14 08:45:38

标签: ios uitableview uiscrollview uigesturerecognizer

正如问题所述,我在UITableView上添加了多个ScrollView - 元素,因此我可以滑动并查看具有不同内容的不同UITableView。奇怪的是,当我点击UITableViewCell时,它无法响应。但是,当我长按UITableViewCell它的工作原理时。 我还在UITapGestureRecognizer上添加了ScrollView,也许这就是原因,但我不知道为什么。

我在_bgScrollView

上添加了几个HRDropDown对象
 #import <UIKit/UIKit.h>
 @class HRDropDownView;
 @protocol HRDropDownViewDelegate <NSObject>

 @optional
 - (void) HRDropDownView:(HRDropDownView *)dropDown didSelectRow:(NSInteger)row;
 -(CGFloat) HRDropDownView:(HRDropDownView*)dropDown heightForRow:(NSInteger)row;
 -(NSInteger) numberOfRows:(HRDropDownView*)dropDown;
 -(UIView *) HRDropDownView:(HRDropDownView *)dropDown viewForRow:(NSInteger)row;
 @end

 @interface HRDropDownView : UIView <UITableViewDelegate, UITableViewDataSource>

 @property (nonatomic, assign) id <HRDropDownViewDelegate> delegate;
 @property (nonatomic, assign, readonly) BOOL isHidden;
 @property (nonatomic, assign) NSUInteger selectedRow;

 -(void)hide;
 - (void)showWithHeight:(CGFloat)height;
 -(void) reloadData;
 @end

喜欢这个

 _venderListView = [[HRDropDownView alloc]initWithFrame:CGRectMake(CGRectGetMinX(_venderTextField.frame)+ 1, CGRectGetMaxY(_venderBgView.frame)  , CGRectGetWidth(_venderBgView.frame) - 2, 0)];
 _venderListView.delegate = self;
 _venderListView.backgroundColor = kWhiteColor;
 [self.bgScrollView addSubview:_venderListView];

之后我添加了像这样的TapGesture

  UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(resignOnTap:)];
 [singleTap setNumberOfTapsRequired:1];
 [singleTap setNumberOfTouchesRequired:1];
 [self.bgScrollView addGestureRecognizer:singleTap];

和resignOnTap:方法如下所示:

 - (void)resignOnTap:(id)iSender {
 [self.currentResponder resignFirstResponder];
 }

0 个答案:

没有答案