You could use the .tag property.
Tags are ints. By default, every view has a tag of 0, but you could assign a different tag to each button as it's created. Interface Builder also allows you to assign tags, if you'll be making your buttons that way. There are methods you can use to say find a button with a certain tag in a certain view. Check the documentation to find the exact method name.
Ok i get it, but (im asking this coz i cant find it) how do i use this with the .center?
Ok i get it, but (im asking this coz i cant find it) how do i use this with the .center?
[(UIView) viewWithTag:(int)].center
Code:[(UIView) viewWithTag:(int)].center
Inserting the superview of the button in place of (UIView) and the tag of the button for (int) would return a CGPoint that represents the center of the button.
(Also, I second what xStep said just before me.)
OK. thx, but.. i dont know what to put there, could you give me an example?Code:[(UIView) viewWithTag:(int)].center
Inserting the superview of the button in place of (UIView) and the tag of the button for (int) would return a CGPoint that represents the center of the button.
(Also, I second what xStep said just before me.)
OK. thx, but.. i dont know what to put there, could you give me an example?
The superview is the view that contains the buttons. Read the UIView documentation and I think you can figure out what to put there. Start at the top in the Overview and then see the superview property.
[_view viewWithTag:1].center
so this is what i got
it just fail with: "Undefined symbols for architecture i386:Code:[_view viewWithTag:1].center
"_OBJC_IVAR_$_UIViewController._view", referenced from:
-[QuineceViewController cambioDePosicion] in QuineceViewController.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status"
any help?
What is _view? Where does it come from? How is it defined?
This is why you'll see people post chunks of code; so that others can understand the context and perhaps even see and describe the error. Use the CODE tag in this forum so that your code gets displayed properly.
- (void)cambioDePosicion{
UIView *view;
[view viewWithTag:1].center = CGPointMake(Button2.center.x , Button2.center.y);
}
Code:- (void)cambioDePosicion{ UIView *view; [view viewWithTag:1].center = CGPointMake(Button2.center.x , Button2.center.y); }
Well, first, that won't work since view isn't instantiated (allocated & initialized). In this case, view is nil.
Second, that view isn't _view from your error that you posted.
- (void)cambioDePosicion{
[_view viewWithTag:1].center = CGPointMake(Button2.center.x , Button2.center.y);
}
so yeah... i have no idea what to do and th code was
Code:- (void)cambioDePosicion{ [_view viewWithTag:1].center = CGPointMake(Button2.center.x , Button2.center.y); }
[self.view viewWithTag:1].center = CGPointMake(Button2.center.x , Button2.center.y);