Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-07-2012, 08:42 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 8
rew0 is on a distinguished road
Default Touch down in one UIButton, drag, and touch up in another UIButton

Hope someone can help - I have searched high and low for and answer to this scenario and have found some related ideas, but nothing concrete yet:

I have a UIView with multiple UIButtons as subviews (sitting above the parent UIView). I have assigned unique Tags to the UIButtons.

I want to handle the following scenario:

Touch down event in one UIButton (and get Tag), drag finger, and then touch up event in another UIButton (and get new Tag).

At the moment the touch up event returns the Tag of the first UIButton wherever I lift my finger on the screen (i.e. within the first UIButton which is what I would expect, or in a second UIButton, or in the gap between buttons (the parent UIView)). I would expect the latter two touch up events to return the Tags of the second UIButton or parent UIView respectively.

Here's the UIButton creation code (inside a loop):
Code:
UIButton *nButton = [UIButton buttonWithType:UIButtonTypeCustom];
[nButton addTarget:self action:@selector(nodeButtonPressed:) forControlEvents:UIControlEventTouchDown];
[nButton addTarget:self action:@selector(nodeButtonReleased:) forControlEvents:UIControlEventTouchUpInside];
// I set other button parameters here...
[self.view addSubview:nButton];
And in the two selector functions I am just reading the Tag of the sender, e.g.:
Code:
- (IBAction)nodeButtonReleased:(id)sender 
{
    UIButton *nodeButton = (UIButton *)sender;
    int nodeId = nodeButton.tag;
    NSLog(@"%i", nodeId);
}
Any guidance?

Thanks,
Rich

Last edited by rew0; 01-07-2012 at 01:53 PM. Reason: Added code
rew0 is offline   Reply With Quote
Reply

Bookmarks

Tags
drag, tag, touch down, touch up, uibutton

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 400
10 members and 390 guests
Atatator, buggen, guusleijsten, j.b.rajesh@gmail.com, morterbaher, QuantumDoja, sacha1996, Sami Gh, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,674
Threads: 94,122
Posts: 402,907
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Atatator
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:35 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0