UITextView inside UIScrollView is not the first responder
I have a UITextView on a view that becomes the first responder.
When I embed a UITextView inside a UIScrollView in the Interface Builder, the UITextView is no longer the first responder. I'm not sure what has changed?
I would like the UITextView to be the first responder.
- (void)viewDidLoad {
[super viewDidLoad];
[scrollView setContentSize:CGSizeMake(540,620)];
composeTextView.delegate = self;
[composeTextView becomeFirstResponder];
}
a source to share
This is my .h file:
#import <UIKit/UIKit.h>
@interface Untitled1ViewController : UIViewController <UITextFieldDelegate> {
UIScrollView *scrollView;
UITextField *composeTextView;
}
@property (nonatomic,retain) IBOutlet UIScrollView *scrollView;
@property (nonatomic,retain) IBOutlet UITextField *composeTextView;
@end
this is my .m file:
#import "Untitled1ViewController.h"
@implementation Untitled1ViewController
@synthesize scrollView;
@synthesize composeTextView;
- (void)viewDidLoad {
[super viewDidLoad];
[scrollView setContentSize:CGSizeMake(540,620)];
composeTextView.delegate = self;
[composeTextView becomeFirstResponder];
}
in IB, I've connected the following: a textField for the composeTextView, a scrollView for the scrollView, and a textField delegate for the owner of the file.
Try again and advise.
a source to share
The text view accepts scroll events, and therefore scroll events are not propagated further down the responder chain. If you are not interested in scrolling the text view, disable scrolling in the textView (use the nib or scrollEnabled property), now the scrollView will start accepting scroll events.
a source to share