SlackTextViewController
SlackTextViewController copied to clipboard
textInputbar incorrect position when embeded in a container view
- [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
- [x] I've read and agree to the Code of Conduct.
- [x] I've searched for any related issues and avoided creating a duplicate issue.
Description
As I add a container view(embeds a SLKTextViewController) to a view controller which has tab bar and navigation bar, the textInputbar does not stick on bottom of SLKTextViewController.view
Reproducible in:
- [x] This is reproducible in the sample project. SlackTextViewController version: 1.9.6 iOS version(s): 11.3, 9.3 Device(s): iPhone X Simulator, iPhone 6 Simulator
Steps to reproduce:
- TabBarController -> NavigationController -> ViewController
- drag a container view into ViewController
- embed a SLKTextViewController in container view
Attachments:
e.g. Logs, screenshots, screencast, sample project, funny gif, etc.
![]()
I am also having this same problem. It seems like the space between the TabBar and the TextInputView is equal to the height of the TabBar... Perhaps this is something to do with the Safe Area Insets?
@dzenbot Can we please get some help on how to fix this issue?
This must related to a miscalculation in slk_appropriateBottomMargin
. Unfortunately this issue isn't reproducible on the sample project, under the "Messenger-Storyboard" target.
@dzenbot Why are you closing an issue that isn't resolved? If there's a miscalculation of slk_appropriateBottomMargin
you need to fix it before closing the issue...
And furthermore, your sample project doesn't embed the SLKTextViewController in a container view as this issue reports....
FYI, this lack of effort on your end is a quick way to get a dev to fix the issue themselves, but not pull back to your repo. Thanks!
I can definitely confirm this, happy to make an example project to demonstrate
ugghh i'm just starting to dig into this but I can also confirm this is only happening with iphoneX
OK, i believe i maybe sort of fixed it by changing
- (CGFloat)slk_appropriateBottomMargin
{
// A bottom margin is required if the view is extended out of it bounds
if ((self.edgesForExtendedLayout & UIRectEdgeBottom) > 0) {
UITabBar *tabBar = self.tabBarController.tabBar;
// Considers the bottom tab bar, unless it will be hidden
if (tabBar && !tabBar.hidden && !self.hidesBottomBarWhenPushed) {
return CGRectGetHeight(tabBar.frame);
}
}
// A bottom margin is required for iPhone X
if (@available(iOS 11.0, *)) {
if (!self.textInputbar.isHidden) {
return self.view.safeAreaInsets.bottom;
}
}
return 0.0;
}
To this:
- (CGFloat)slk_appropriateBottomMargin
{
// A bottom margin is required for iPhone X
if (@available(iOS 11.0, *)) {
if (!self.textInputbar.isHidden) {
return self.view.safeAreaInsets.bottom;
}
}
// A bottom margin is required if the view is extended out of it bounds
if ((self.edgesForExtendedLayout & UIRectEdgeBottom) > 0) {
UITabBar *tabBar = self.tabBarController.tabBar;
// Considers the bottom tab bar, unless it will be hidden
if (tabBar && !tabBar.hidden && !self.hidesBottomBarWhenPushed) {
return CGRectGetHeight(tabBar.frame);
}
}
return 0.0;
}
Instinctively if i'm running ios11 i don't like the early return that's what made me want to change the order of this short circuit
Ok i ran the original source code again with the following debugging information
NSLog(@"tabBar %@", tabBar);
NSLog(tabBar.hidden ? @"TAB BAR HIDDEN" : @"TAB BAR NOT HIDDEN");
NSLog(self.hidesBottomBarWhenPushed ? @"hidesBottomBarWhenPushed" : @"DOES NOT hidesBottomBarWhenPushed");
// Considers the bottom tab bar, unless it will be hidden
if (tabBar && !tabBar.hidden && !self.hidesBottomBarWhenPushed) {
NSLog(@"********************");
return CGRectGetHeight(tabBar.frame);
}
2018-08-17 22:09:56.782764-0700 SPAR[10161:4441910] tabBar <UITabBar: 0x129e4af10; frame = (-375 729; 375 83); autoresize = W+TM; tintColor = UIExtendedGrayColorSpace 0 1; gestureRecognizers = <NSArray: 0x1d404d170>; animations = { position=<CABasicAnimation: 0x1d423d680>; }; layer = <CALayer: 0x1d0235760>>
2018-08-17 22:09:56.782781-0700 SPAR[10161:4441910] TAB BAR NOT HIDDEN
2018-08-17 22:09:56.782790-0700 SPAR[10161:4441910] DOES NOT hidesBottomBarWhenPushed
2018-08-17 22:09:56.782801-0700 SPAR[10161:4441910] ********************
Ok @TannerJuby01 @minuslu, i figured it out.
