Reputation: 1462
I've looked for this everywhere and I can't find a solution...
My Goal: I'm trying to edit a label in my storyboard without creating an outlet specifically for that label (I have 36 labels).
Problem: I tried this basic line of code that I found on another Stack Overflow question, but it didn't succeed and I got an error...
UILabel *label = (UILabel *)[self viewWithTag:71];
Error: No visible @interface for 'ViewControllerTwo' declares the selector 'viewWithTag:'
Any help will be appreciated...
Upvotes: 3
Views: 3124
Reputation: 3905
just as @Paul.s said, IBOutletCollection
may be a better way. Just in case you need IBOutletCollection
:
@property (nonatomic, strong) IBOutletCollection(UILabel) NSArray *labels;
Or in Swift:
@IBOutlet var imageViews: [UIImageView]!
Upvotes: 0
Reputation: 38728
Change your code to
|
v
UILabel *label = (UILabel *)[self.view viewWithTag:71];
UIViewController
does not have viewWithTag:
, UIView
does
Upvotes: 9
Reputation: 6651
viewwithTag is a method on UIView not on UIViewController. You'll probably have to call it like this:
UILabel *label = (UILabel *)[self.view viewWithTag:71];
Upvotes: 4
Reputation: 2236
Try using self.view
:
UILabel *label = (UILabel *)[self.view viewWithTag:71];
Upvotes: 1