Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

textInputbar incorrect position when embeded in a container view #668

Open
4 tasks done
minuslu opened this issue May 3, 2018 · 10 comments
Open
4 tasks done

textInputbar incorrect position when embeded in a container view #668

minuslu opened this issue May 3, 2018 · 10 comments

Comments

@minuslu
Copy link

minuslu commented May 3, 2018

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • 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:

  • 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:

  1. TabBarController -> NavigationController -> ViewController
  2. drag a container view into ViewController
  3. embed a SLKTextViewController in container view

Attachments:

e.g. Logs, screenshots, screencast, sample project, funny gif, etc.

iphonex

storyboard

@ghost
Copy link

ghost commented Jul 2, 2018

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?

@ghost
Copy link

ghost commented Jul 23, 2018

@dzenbot Can we please get some help on how to fix this issue?

@dzenbot
Copy link

dzenbot commented Aug 17, 2018

This must related to a miscalculation in slk_appropriateBottomMargin. Unfortunately this issue isn't reproducible on the sample project, under the "Messenger-Storyboard" target.

@TannerJuby1
Copy link

@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...

@TannerJuby1
Copy link

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!

@rromanchuk
Copy link

I can definitely confirm this, happy to make an example project to demonstrate

@rromanchuk
Copy link

ugghh i'm just starting to dig into this but I can also confirm this is only happening with iphoneX
screen shot 2018-08-17 at 9 49 58 pm

@rromanchuk
Copy link

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

@rromanchuk
Copy link

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] ********************

rromanchuk added a commit to rromanchuk/SlackTextViewController that referenced this issue Aug 18, 2018
…may cuase SLKTextViewController to calculate incorrect bottom margin calculations. slackhq#668
@rromanchuk
Copy link

Ok @TannerJuby01 @minuslu, i figured it out.

inbox_storyboard_and_textinputbar_incorrect_position_when_embeded_in_a_container_view_ _issue__668_ _slackhq_slacktextviewcontroller

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants