send three variables on button clicked - MacRumors Forums
Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 3, 2011, 01:41 PM   #1
todizara
macrumors newbie
 
Join Date: Dec 2010
send three variables on button clicked

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.
todizara is offline   0 Reply With Quote
Old Feb 4, 2011, 05:52 PM   #2
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by todizara View Post
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.
__________________
dejo is offline   0 Reply With Quote
Old Feb 4, 2011, 08:37 PM   #3
todizara
Thread Starter
macrumors newbie
 
Join Date: Dec 2010
Quote:
Originally Posted by dejo View Post
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.
todizara is offline   0 Reply With Quote
Old Feb 4, 2011, 11:44 PM   #4
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by todizara View Post
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.
__________________
dejo is offline   0 Reply With Quote
Old Feb 5, 2011, 12:27 AM   #5
todizara
Thread Starter
macrumors newbie
 
Join Date: Dec 2010
Quote:
Originally Posted by dejo View Post
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.
todizara is offline   0 Reply With Quote
Old Feb 5, 2011, 12:33 AM   #6
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by todizara View Post
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.
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.
__________________
dejo is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
NSMutableDictionary and a button to send changes Carll iPhone/iPad Programming 12 Jan 12, 2013 08:19 AM
All iPads: Apple wireless keyboard SEND button? iHawaii iPad Accessories 3 Nov 20, 2012 05:35 PM
Resolved: Add content form a UITextfield to an NSMutableArray everytime a button is clicked fstigre iPhone/iPad Programming 13 Nov 17, 2012 09:07 AM
Bind enter key to FB Messenger send button markgixxer750 iPhone 3 Nov 5, 2012 08:44 AM
SearchBar Search Button Clicked Error loon3y iPhone/iPad Programming 6 Jun 20, 2012 06:40 PM

Forum Jump

All times are GMT -5. The time now is 05:41 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC