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 11-05-2011, 09:37 PM   #1 (permalink)
Registered Member
 
Join Date: Nov 2011
Posts: 5
polymaker is on a distinguished road
Question Touch event on UIScrollView

I am new to xcode and mac and I try to do a little app. The app is a kind of twitter. I managed to make a function that connect on my webserver and by a php request, insert the message from a textbox into my databse. Now I want to show the messages from the database on the iphone. The problem is not to get the data (I didn't tried, but I know I have to parse a XML) but to display the messages. I first used a UITableView, the problem is that it doesn't have a touch event. I changed to a UIScrollView and the problem was the same. I need the touch event to be able to close the textbox keyboard. Before having the table or scroll view, to close the keyboard, I changed the class of the viewcontroller to UIControl that have touch up inside and then the closing event was fired by tapping the background.

It is a simple UIViewController with an UIScrollView on it. I am able to display message in the scrollview by adding a UIImageView subview with a label on it and the avatar picture. Now I need to detect touch on the scrollview. I have read to implement touchesEnded in a scrollView subclass. So I tried and I almost got it working.
I created TouchableScrollView.h

Code:
#import <UIKit/UIKit.h>

@interface TouchableScrollView : UIScrollView

@end
and TouchableScrollView.m
Code:
- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event 
{   
        [super touchesEnded: touches withEvent: event];
}
I have changed my scrollview class for TouchableScrollView. And to test I added NSLog(@"touch") in the touchesEnded in TouchableScrollView.m. When running the app it print in the debug "touch" when I touch the scroll view. So it work, but I need to catch the event in myviewController.m because the textbox is in it. How do I do that?

Maybe there is an easier way to do what I want, and I'm all wrong, but I really need help. And sorry if some phrases don't make sense, I'm french.
polymaker is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, uiscrollview, xcode

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: 402
17 members and 385 guests
7twenty7, Alex-alex, Apptronics RBC, baja_yu, dre, FrankWeller, gwelmarten, ipodphone, jeroenkeij, jleannex55, matador1978, n00b, pbart, reficul, Retouchable, Sami Gh, usernametaken
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,125
Posts: 402,910
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

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