MessageComposerView
MessageComposerView copied to clipboard
Placement of the MessageComposerView
When having a UITableViewController within a UITabBarController, the MessageComposerView gets below the bottom bar. There should be a way to force it further up.
Thanks for pointing that out, I'll get to it as soon as possible. For reference what iOS version are you targeting?
Thats great! The version of iOS is 7.1.1
Sorry for the delay. It looks like when I first wrote this I didn't account for the fact that user's may want to modify the margin between the MessageComposerView and the bottom of the keyboard so that functionality doesn't exist yet. I'm going to make a few improvements to the code to allow for this as well as finally look into iOS 7 compatibility issues.
So that you don't have to wait for me - if you'd like to edit this yourself, the library works by offsetting the MessageComposerView via the size returned by the currentScreenSize function (among other things). As a quick hack you can edit this value how you like to change the offset from the bottom by making the "screenSize" smaller or larger, e.g.
- (CGSize)currentScreenSize {
CGSize screenSize = [self currentScreenSizeInInterfaceOrientation:[self currentInterfaceOrientation]];
screenSize.height += 20;
return screenSize;
}
As for handling a UITabBarController, I'm assuming you want the MessageComposerView above the tab bar both when keyboard is up and down. If that's the case then a static margin might be ok. If you're only showing the tab bar when the keyboard is down, you'll have to do a bit more fiddling, as you'll now have two separate margins, one for when the keyboard is down and another for when it's active.
If you get a working solution, please let me know! Thanks
As of 1.1.0 I added an alternate initializer initWithFrame:andKeyboardOffset: that accepts a static int offset from the bottom of the screen/top of the keyboard. I also fixed a few issues related to iOS7 such as problems with the animation curve and issues with positioning due iOS7s change to a overlaying status bar. Let me know if that works :)
I recently had the same issue. I add an NSString in both textview delegate methods (beingEditing and endEditing) and I set an IF ELSE (Not IF, ELSE IF) on the NSString set in the beginEditing method. I got rid of the _keyboardHeight instance and change it to 49(height of TabBar). This is what it looks like
if ([self.heightNeeded isEqualToString:@"Lower"]) {
frame.origin.y = ([self currentScreenSize].height - [self currentKeyboardHeight]) - frame.size.height;
} else {
frame.origin.y = ([self currentScreenSize].height - [self currentKeyboardHeight]) - frame.size.height - 49;
}
This i put in the "layoutSubview" method This method get called initially when loading and when the keyboard comes up and goes down.
@yuppielabel
Could you not initialize the MessageComposerView via initWithKeyboardOffset:49 andMaxHeight:CGFLOAT_MAX? This should provide you with the desired result without requiring you to edit the lib manually
@oseparovic it starts off initially above the tabbar but when the keyboard goes up, that offset stays the same and the input view is mantains that offset above the keyboard. So there is a huge space.
Ah I see. Then initWithKeyboardOffset:andMaxHeight is definitely not the right function for the job. Perhaps I need to add another initializer for that scenario. Please contact me via my contact form here http://www.thegameengine.org/contact/ and I'll email you back asap.
I mean what ever I am doing here seems to be working. But I have also found some more complex messagingviewcontrollers like SOMessagingViewController and JSQMessagingViewController. So I am going to give those a shot
On Feb 11, 2015, at 2:40 PM, oseparovic [email protected] wrote:
Ah I see. Then initWithKeyboardOffset:andMaxHeight is definitely not the right function for the job. Perhaps I need to add another initializer for that scenario. Please contact me via my contact form here http://www.thegameengine.org/contact/ http://www.thegameengine.org/contact/ and I'll email you back asap.
— Reply to this email directly or view it on GitHub https://github.com/oseparovic/MessageComposerView/issues/1#issuecomment-73949248.
I ran into this same problem trying to use this over a tab bar, so I set the keyboard offset to 50 and then I went into your .m file and change the keyboard height to self.keyboardHeight - 50. I'm not sure that's the best way to do it, but it works.
- (CGFloat)currentKeyboardHeight {
if ([self.messageTextView isFirstResponder]) {
return self.keyboardHeight - 50;
} else {
return 0;
}
}
That sounds pretty reasonable. I'm still trying to find a good way to determine if the parent is a UITabBarController from within the MessageComposerView but it's tricky. Thanks for your suggestion