I am creating a messaging app for iPhone. I want the user to have the capability of entering a newline while pressing return. But I am having trouble putting a UITextview inside the toolbar item. I have seen the same with UITextView. When return key is pressed i want to get the new line in UITextField.Is this possible.
Please help Thanks in advance.
You can't add it using IB but you can do it programmatically. You will need to set its contentInset
so that the text content is not pushed up on editing because the content will become invisible due to the text view's constrained size. I have added that in the example code below.
UITextView * textView = [[[UITextView alloc] initWithFrame:CGRectMake(0, 0, 100, 32)] autorelease];
textView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
UIBarButtonItem * barItem = [[[UIBarButtonItem alloc] initWithCustomView:textView] autorelease];
self.toolbar.items = [NSArray arrayWithObject:barItem];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With