Can I get the element by Tag from iOS?

后端 未结 3 748
无人及你
无人及你 2020-12-25 12:27

I want to get back a button, I\'ve already assign the tag to there, how can I do so?

3条回答
  •  囚心锁ツ
    2020-12-25 12:56

    //Get View using tag
            UITextField *textFieldInView = (UITextField*)[self.view viewWithTag:sender.tag+1000];
            UILabel *labelInView = (UILabel*)[self.view viewWithTag:sender.tag+2000];
    
    //Print its content based on the tags
            NSLog(@"The tag is %d ", textFieldInView.tag);
            NSLog(@"The tag is %d ", labelInView.tag);
            NSLog(@"The Content is %@ ", textFieldInView.text);
            NSLog(@"The Content is  %@ ", labelInView.text);
    

提交回复
热议问题