iOS 局部变量 setTag后可在别的地方调用 viewWithTag

来源:互联网 发布:visio网络拓扑图模具 编辑:程序博客网 时间:2024/04/29 10:47
//比如在某个方法里设置后UITextField* testFild=[[UITextField alloc] initWithFrame:CGRectMake(0, 48, 200, 200)];    testFild.text = @"qingjoin";    testFild.tag = bbbb;    [self.view addSubview:testFild];//在另一个方法里面也可以得到这个值 UITextField *t = (UITextField*)[self.view viewWithTag:bbbb];    NSLog(@"ttfftf:%@",t.text);