iOS-在UILabel中设置值,值返回UILabel
来源:互联网 发布:yy mac进入房间失败 编辑:程序博客网 时间:2024/06/14 10:31
- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib.//添加标签的点击手势 l = [[UILabel alloc] initWithFrame:CGRectMake(60, 90, 100, 50)]; l.userInteractionEnabled=YES; UITapGestureRecognizer *labelTapGestureRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(labelTouchUpInside:)]; l.backgroundColor = [UIColor redColor]; [l addGestureRecognizer:labelTapGestureRecognizer]; [self.view addSubview:l];}-(void) labelTouchUpInside:(UITapGestureRecognizer *)recognizer{ UILabel *label=(UILabel*)recognizer.view; NSLog(@"%@被点击了",label.text); UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"设置昵称" message:@"请输入昵称" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil]; [alertView setAlertViewStyle:UIAlertViewStylePlainTextInput]; [alertView show];}#pragma mark 获得输入框里的值- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{ NSString *buttonTitle = [alertView buttonTitleAtIndex:buttonIndex]; if ([buttonTitle isEqualToString:@"确定"]){ UITextField *tf=[alertView textFieldAtIndex:0];//获得输入框 NSString * res = tf.text;//获得值 NSLog(@"%@",res); l.text = res; }}
阅读全文
0 0
- iOS-在UILabel中设置值,值返回UILabel
- iOS设置UILabel组件
- ios- UILabel - 相关设置
- IOS中UILabel排版
- iOS中UILabel属性
- ios中uilabel换行
- 在iOS中UILabel作为一个文本标签,在实现程序中几乎每个页面都会用到UILabel,UILabel的常用属性:textColor(文本颜色),text(文本值),font(文本字体),textA
- iOS 设置UILabel的背景图片
- iOS:设置UILabel行距实例
- ios UILabel设置行间距
- IOS UILabel 设置圆角
- iOS UILabel 设置行间距
- iOS:设置UILabel行距实例
- 关于iOS UILabel 设置 UIEdgeInsets
- iOS UILabel设置行间距
- iOS UILabel设置行间距
- iOS中UILabel和UIButton的自定义设置
- iOS中UILabel + NSString字体样式的设置
- React Native之属性统一配置类似安卓
- 传感器
- 团队天梯赛L1-004. 计算摄氏温度
- gradle构建样例
- Activity-setContentView(int resId)源码分析
- iOS-在UILabel中设置值,值返回UILabel
- 16位加法器和字符数组调试时的一些问题
- J2EE中容器
- MySql模糊查询
- XPath与lxml类库
- Java Web框架对比:SSH和SSM
- 在CentOS7.2中安装htop 安装 和 supervisor
- 东方贵族夫人放大招:CBK会员余额换购皮草
- python绘制散点图并标记序号