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 08-19-2010, 05:25 AM   #1 (permalink)
Registered Member
 
Join Date: Jan 2010
Posts: 1
Gubb is on a distinguished road
Default UIButton in scrollview with subview not responding to touch-events

Heya, I've been struggling with an extremely annoying problem for many hours now and I decided that I'd better ask for help. I've tried to google my problem and found a couple of similar threads but nothing that gave an answer that helped me.

Here goes:

In my viewcontrollers main view i have a scollview which contains a couple of subview. One of these subview have a UIButton in it which when clicked adds another subview to its superview. This newly added view contains a UIButton(that will be used to remove the added view), this button is my problem, it doesn't respond to touch-events at all...

code:
Code:
subview = [[UIView alloc] initWithFrame:frame];
[viewAddedInIB addSubview:subView];

UIButton *removeButton = [UIButton ButtonWithType:UIButtonTypeCustom];
[removeButton setFrame:buttonFrame];
[removeButton setBackgroundImage:[UIImage imageNamed:@"remove.png"]];
[removeButton addTarget:self action:@selector(onPress:) forControlEvents:UIControlEventTouchUpInside];
[subView addSubview:removeButton];

Last edited by Gubb; 08-19-2010 at 06:02 AM.
Gubb is offline   Reply With Quote
Old 09-13-2010, 10:24 PM   #2 (permalink)
Registered Member
 
Join Date: Oct 2008
Posts: 247
c0der is on a distinguished road
Default

Did you find a solution? I'm having the same problem.
c0der is offline   Reply With Quote
Old 09-14-2010, 05:15 AM   #3 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 62
devanshree.c is on a distinguished road
Thumbs up

Quote:
Originally Posted by Gubb View Post
Heya, I've been struggling with an extremely annoying problem for many hours now and I decided that I'd better ask for help. I've tried to google my problem and found a couple of similar threads but nothing that gave an answer that helped me.

Here goes:

In my viewcontrollers main view i have a scollview which contains a couple of subview. One of these subview have a UIButton in it which when clicked adds another subview to its superview. This newly added view contains a UIButton(that will be used to remove the added view), this button is my problem, it doesn't respond to touch-events at all...

code:
Code:
subview = [[UIView alloc] initWithFrame:frame];
[viewAddedInIB addSubview:subView];

UIButton *removeButton = [UIButton ButtonWithType:UIButtonTypeCustom];
[removeButton setFrame:buttonFrame];
[removeButton setBackgroundImage:[UIImage imageNamed:@"remove.png"]];
[removeButton addTarget:self action:@selector(onPress:) forControlEvents:UIControlEventTouchUpInside];
[subView addSubview:removeButton];
You have to override the NSTouch methods for UIScrollViews!
I had the same problem but solved it by overriding the touchesBegan,touchesEnd methods
devanshree.c is offline   Reply With Quote
Reply

Bookmarks

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: 343
5 members and 338 guests
freewind, givensur, lendo, Newbie123, PlutoPrime
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,894
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

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