Just like the title says... How can I do that? I want the user to enter lots of text, and then somehow minimize the keyboard and go back to interacting with other objects in that view. However, they may need the "enter" key available for formatting their text while typing. Any suggestions?
Anil suggested a link that included the following code:
(void)textViewDidBeginEditing:(UITextView *)textView {
[self createInputAccessoryView];
[textView setInputAccessoryView:_inputAccessoryView];
self.myTextView = textView; }
-(void)createInputAccessoryView {
_inputAccessoryView = [[UIToolbar alloc] init];
_inputAccessoryView.barStyle = UIBarStyleBlackOpaque;
[_inputAccessoryView sizeToFit];
_inputAccessoryView.frame = CGRectMake(0,_collageView.frame.size.height - 44, _collageView.frame.size.width, 44);
UIBarButtonItem *fontItem = [[UIBarButtonItem alloc] initWithTitle:@"Font"
style:UIBarButtonItemStyleBordered
target:self action:@selector(changeFont:)];
UIBarButtonItem *removeItem = [[UIBarButtonItem alloc] initWithTitle:@"Remove"
style:UIBarButtonItemStyleBordered
target:self action:@selector(removeTextView:)];
//Use this to put space in between your toolbox buttons
UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace
target:nil
action:nil];
UIBarButtonItem *doneItem = [[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonItemStyleDone
target:self action:@selector(dismissKeyBoard:)];
NSArray *items = [NSArray arrayWithObjects:fontItem,removeItem,flexItem,doneItem, nil];
[_inputAccessoryView setItems:items animated:YES];
[_myTextView addSubview:_inputAccessoryView];
}
However, i am a bit behind the curve conceptually...Where do I put the reference to my TextView, the .h or .m file? I don't see how...
-(void)textViewDidBeginEditing:(UITextView *)textView {
...links to my actual TextField. Also, xcode is throwing an error for "_inputAccessoryView" saying that is isn't defined anywhere. Your help is very much appreciated!