Im trying to Insert the current date/time whenever the users hits the return key or starts typing on a UITextView in Xcode but not quite sure where to start.
I know this method is for when clicking into the TextView but doesn't seem to work:
- (void)textViewDidBeginEditing:(UITextView *)textView {
self.txtDetail.text = [self.txtDetail.text stringByAppendingString:@"Hello!"];
}
Thanks
Update:
DetailViewController.h
@interface DetailViewController : UIViewController <UIPopoverControllerDelegate, UISplitViewControllerDelegate> {
UITextView *txtDetail;
}
@property (nonatomic, retain) IBOutlet UITextView *txtDetail;
- (void)textViewDidBeginEditing:(UITextView *)textView;
DetailViewController.m
@synthesize txtDetail;
- (void)textViewDidBeginEditing:(UITextView *)textView {
NSLog(@"Hello");
self.txtDetail.text = [self.txtDetail.text stringByAppendingString:@"Hello!"];
}
Update02:
Ive added this to my .m files:
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
BOOL shouldChangeText = YES;
if ([text isEqualToString:@"\n"]) {
// Find the next entry field
txtDetail.text = [txtDetail.text stringByAppendingString:@"\nhey\n"]; }
textView.editable = YES;
shouldChangeText = NO;
[textView becomeFirstResponder];
return shouldChangeText;
}
I get the desired effect (Hey is added in whenever i press return on the keyboard) but i now can't type anything... any ideas?