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

View Single Post
Old 01-03-2011, 05:17 PM   #4 (permalink)
macken
Registered Member
 
Join Date: Jan 2011
Posts: 1
macken is on a distinguished road
Smile

Quote:
Originally Posted by sbudhram View Post
So, a little more info, but no solution.

First, I tried subclassing the scroll view to access the touchesBegan/touchesEnded/touchesMoved methods, and just using NSLogs to make sure they were being called. Which they were! I could see that dragging/pressing was triggering the methods for my subclass.

However, if I pressed on something within my scrollview like a button, these methods were NOT called (including my picker). I'm guessing this is because they implement their own touch methods that get precedence over the scrollView. So, next I tried to subclass the picker and use the touchesBegan/Ended methods. No luck, they are not being called. And on top of that, dragging in the picker still triggers the scrollView, though it doesn't trigger the scrollView's touchesBegan/Ended methods that I implemented.

Still looking for a solution. If there are any event handling gurus out there, please speak out!

Thanks.
Firstly I am definitely no guru, but I got this to work by creating a UIScrollView subclass and overriding the following methods

HTML Code:
@interface PickerAwareUIScrollView : UIScrollView {
}
- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view;
- (BOOL)touchesShouldCancelInContentView:(UIView *)view;

implementation

- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view {
if ([view isKindOfClass:[UIPickerView class]] || [@"UIPickerTable" isEqualToString:[[view class] description]] ) {
//|| [view isKindOfClass:[UIPicker class]]
return YES;
}
return [super touchesShouldBegin:touches withEvent:event inContentView:view];
}

- (BOOL)touchesShouldCancelInContentView:(UIView *)view {
if ([view isKindOfClass:[UIPickerView class]] || [@"UIPickerTable" isEqualToString:[[view class] description]] ) {
return NO;
}
return [super touchesShouldCancelInContentView:view];
}

This cancels the touch handling in the scrollView when the event is inside the UIPickerView.
macken is offline   Reply With Quote
 

» Advertisements
» Online Users: 403
11 members and 392 guests
antonwilliams, Chickenrig, CMSLdesign, dre, LEARN2MAKE, Paul Slocum, roof44, ryantcb, spinyanteater, Trickphotostudios, waterkamp
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,591
Threads: 94,083
Posts: 402,778
Top Poster: BrianSlick (7,990)
Welcome to our newest member, guillermotricia
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:39 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.