选中下拉框的位置变化
来源:互联网 发布:keeper软件默认密码 编辑:程序博客网 时间:2024/05/03 12:27
@interface ViewController () <UITableViewDelegate,UITableViewDataSource> {
}
@property (nonatomic,weak)UITableView *listView;
@property (nonatomic,strong)NSArray *arrays;
@property (nonatomic,strong) UILabel *label1;
@property (nonatomic,strong) UILabel *label2;
@property (nonatomic,strong)UITapGestureRecognizer *tapLabel;
@end
- (UITableView *)listView{
if (!_listView) {
UITableView *listView = [[UITableViewalloc]init];
listView.delegate = self;
listView.dataSource = self;
listView.backgroundColor = [UIColororangeColor];
listView.layer.borderWidth =1.0;
listView.layer.cornerRadius =6.0;
listView.separatorStyle =UITableViewCellSeparatorStyleNone;
listView.layer.borderColor = [UIColorblueColor].CGColor;
[self.viewaddSubview:listView];
_listView = listView;
}
return_listView;
}
- (void)viewDidLoad {
[superviewDidLoad];
self.arrays =@[@"1",@"2",@"3",@"4",@"5"];
// self.showList = NO;
UITapGestureRecognizer *tap = [[UITapGestureRecognizeralloc]init];
[tap addTarget:selfaction:@selector(tapGes:)];
[self.coveraddGestureRecognizer:tap];
UILabel *label1 = [[UILabelalloc]initWithFrame:CGRectMake(40,200,160, 20)];
label1.layer.borderWidth =1;
label1.layer.cornerRadius =8.0;
label1.layer.borderColor = [[UIColororangeColor]CGColor];
label1.userInteractionEnabled =YES;
[self.viewaddSubview:label1];
self.label1 = label1;
self.tapLabel = [[UITapGestureRecognizeralloc]init];
[self.tapLabeladdTarget:selfaction:@selector(tapGes:)];
[label1 addGestureRecognizer:self.tapLabel];
label1.tag = 1000;
UILabel *label2 = [[UILabelalloc]initWithFrame:CGRectMake(40,500,160, 20)];
label2.layer.borderWidth =1;
label2.layer.cornerRadius =6.0;
label2.layer.borderColor = [[UIColorredColor]CGColor];
label2.userInteractionEnabled =YES;
[self.viewaddSubview:label2];
self.label2 = label2;
self.tapLabel = [[UITapGestureRecognizeralloc]init];
[self.tapLabeladdTarget:selfaction:@selector(tapGes:)];
[label2 addGestureRecognizer:self.tapLabel];
label2.tag = 1001;
}
- (void)tapGes:(UITapGestureRecognizer *)tap{
self.tapLabel = tap;
CGFloat height = self.arrays.count*20;
CGRect rect = [tap.view.superviewconvertRect:tap.view.frametoView:self.view];
CGFloat listX = rect.origin.x;
CGFloat listY = CGRectGetMaxY(rect);
CGFloat listW = rect.size.width;
CGFloat listH = height;
CGFloat vcH = self.view.frame.size.height;
if (vcH - (listY+listH) >10) {
self.listView.frame =CGRectMake(listX, listY, listW, listH);
}else{
self.listView.frame =CGRectMake(listX, listY-20-listH, listW, listH);
}
[self.viewaddSubview:self.listView];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [self.arrayscount];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *listCell =@"listCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:listCell];
if (cell == nil) {
cell = [[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:listCell];
}
UIView *lineView = [[UIViewalloc]initWithFrame:CGRectMake(0,20, tableView.frame.size.width,1)];
lineView.backgroundColor = [UIColorblueColor];
[cell.contentView addSubview:lineView];
cell.textLabel.text = [self.arraysobjectAtIndex:indexPath.row];
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
return 20;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *textStr = [self.arraysobjectAtIndex:indexPath.row];
[tableView removeFromSuperview];
if (self.tapLabel.view.tag ==1000) {
self.label1.text = [NSStringstringWithFormat:@" %@",textStr];
}else if (self.tapLabel.view.tag ==1001){
self.label2.text = [NSStringstringWithFormat:@" %@",textStr];
}else{
self.textField1.text = textStr;
}
}
- 选中下拉框的位置变化
- jquery select change下拉框选项变化判断选中值
- jquery select change下拉框选项变化判断选中值
- jquery select change下拉框选项变化判断选中值
- 实现随着 下拉菜单中 选中值的变化 周边的值也也跟着变化。(使用【 VLOOKUP 】 函数)
- 两个下拉框的动态变化
- select 下拉框编辑的时候,选中
- JS获取下拉框选中的值
- 获取下拉框选中的label
- 获取select下拉框选中的值
- js 下拉框选中的值
- 获取select下拉框的选中值
- 获取下拉框选中的值
- 设置下拉框选中的值
- js操作下拉框选中的值
- select获取下拉框的值 下拉框默认选中
- 选中下拉框
- 下拉框选中跳转
- lua脚本demo实例
- oracle相关SQL
- zabbix安装
- 纯收藏----纯收藏
- Java基础之内部类---匿名内部类
- 选中下拉框的位置变化
- orcale
- Mybaits Generator自动生成代码
- 理解jquery的$.extend()、$.fn和$.fn.extend()
- ssm框架
- C++通过ADO访问SQLSERVER/ORACLE数据库
- Cookie 中存放中文的问题
- Mini-project #4 - Pong
- QMenu