正如问题所述,我在UITableView
上添加了多个ScrollView
- 元素,因此我可以滑动并查看具有不同内容的不同UITableView
。奇怪的是,当我点击UITableViewCell
时,它无法响应。但是,当我长按UITableViewCell
它的工作原理时。
我还在UITapGestureRecognizer
上添加了ScrollView
,也许这就是原因,但我不知道为什么。
#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];
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(resignOnTap:)];
[singleTap setNumberOfTapsRequired:1];
[singleTap setNumberOfTouchesRequired:1];
[self.bgScrollView addGestureRecognizer:singleTap];
- (void)resignOnTap:(id)iSender {
[self.currentResponder resignFirstResponder];
}