在下面的代码中,我想要-firstView-的任何标识符,如下面的代码所示。我尝试了以下操作:
//NSLog(@"_[uiviews[0] _description] = %@" , [uiviews[0] _description]);
//NSLog(@"[uiviews[0] nameLabel] = %@" , [uiviews[0] nameLabel]);
//NSLog(@"[uiviews[0] textLabel]= %@" , [[uiviews[0] textLabel].text);
NSString *r = [uiviews[0] textLabel].text;
NSLog(@"[uiviews[0] textLabel]= %@", r);a
但是,一旦激活其中任何一个,应用程序就会崩溃。您能否让我知道如何访问名称或标识该UIView的任何字符串。
code
UIView *firstView = uiviews[0];
使用UIView.tag
识别您的应用中的视图:
UIView* anotherView = [UIView new];
anotherView.tag = 100;
[view addSubview:anotherView];
UIView* anotherViewAgain = [view viewWithTag:100];