Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

todizara

macrumors newbie
Original poster
Dec 17, 2010
29
0
Hi!
I want to send three variables when clicking a button, the first is the tag and the other two I do not know how to declerer they.
 
I want to send three variables when clicking a button, the first is the tag and the other two I do not know how to declerer they.
You're going to have to be a lot more specific than that. Please elaborate. Also, what do you mean by "send"? And to what? What is the purpose of the three variables and what types are they? Etc. Details like this are important.
 
You're going to have to be a lot more specific than that. Please elaborate. Also, what do you mean by "send"? And to what? What is the purpose of the three variables and what types are they? Etc. Details like this are important.

I mean by "send" is when I click on a button I can get these three variable by the action of this button. These variables are all integer.
The first variable is the tag, and the other two will be coordinated (x and y) from the button.
 
I mean by "send" is when I click on a button I can get these three variable by the action of this button. These variables are all integer.
The first variable is the tag, and the other two will be coordinated (x and y) from the button.
Well, if your IBAction is constructed in such a way that it accepts an (id)sender parameter, than you can typecast the sender into a UIButton and then just reference its tag property (actually inherited from UIView).

As for getting the x,y coordinates, I'm not sure how you would do that but normally they are determined in reference to the top-left corner, not the bottom.
 
Well, if your IBAction is constructed in such a way that it accepts an (id)sender parameter, than you can typecast the sender into a UIButton and then just reference its tag property (actually inherited from UIView).

As for getting the x,y coordinates, I'm not sure how you would do that but normally they are determined in reference to the top-left corner, not the bottom.
I declared the button as
Code:
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	myButton.frame = CGRectMake(40,60, 50, 50); 
	[myButton setTitle:[NSString stringWithFormat: @"%d",value] forState:UIControlStateNormal];
	myButton.tag =6;
	[myButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
here x=40, y=50
my problem is now the other two variables.
 
I declared the button as
Code:
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
	myButton.frame = CGRectMake([COLOR="Red"]40,60,[/COLOR] 50, 50); 
	[myButton setTitle:[NSString stringWithFormat: @"%d",value] forState:UIControlStateNormal];
	myButton.tag =6;
	[myButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
here x=40, y=50
my problem is now the other two variables.
Don't you mean x = 40, y = 60 ?
And if you just want the x/y coordinates of the origin of the UIButton, those too can be referenced by accessing them through the "property chain" starting with the UIButton's frame.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.