Reputation: 1237
I was wondering how to grab an instance of a UIButton without interacting with it. I have placed a button in my xib, and just want to be able to get it's position in code. I have created an IBOutlet and linked them up, but when I look at the position of the IBOutlet it is set to 0,0.
Any help is much appreciated.
Kind Regards, Elliott
Upvotes: 0
Views: 726
Reputation: 19418
you have to set tag
property of that but button, say 1001, and for example in viewDidLoad
method you can get that button by :
- (void) viewDidLoad
{
UIButton *temp = (UIButton *)[self.view viewWithTag:1001];
NSLog(@"%f",temp.frame.origin.x);
NSLog(@"%f",temp.frame.origin.y);
}
Hope it helps you...
Upvotes: 1