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.