slackhq / SlackTextViewController

⛔️**DEPRECATED** ⛔️ A drop-in UIViewController subclass with a growing text input view and other useful messaging features
https://slack.com/
MIT License
8.32k stars 1.08k forks source link

Message bubble is behind keyboard. #580

Open yarodevuci opened 7 years ago

yarodevuci commented 7 years ago

Most of the time if the message has new lines it ends up partially hidden behind the keyboard. Any ideas how to fix that? @dzenbot img_0576

adamsrosco commented 7 years ago

hi @yarodevuci,

is this when the keyboard first pops up, or are you unable to scroll the message for it to appear fully in view?

yarodevuci commented 7 years ago

@adamsrosco That's when keyboard is up and I press send button. That's how new message appears

yarodevuci commented 7 years ago

@adamsrosco or @dzenbot Any word on that?

Smnelson13 commented 7 years ago

How were you able to make the text inside of the label have a cushion around it? my label shrinks to the size of the text and ends up looking like this. I used the pod to create a app that talks with cleverbot.

screen shot 2017-04-24 at 12 14 19 pm
adamsrosco commented 7 years ago

@yarodevuci you have to shift your content view of the tableView so the tableView will appear to shift higher. So you would need to monitor the UIKeyboardShown and dissappear events, and shift the keyboard.

adamsrosco commented 7 years ago

@Smnelson13 are you using the AL chat cells to generate your chat bubbles?

adamsrosco commented 7 years ago

@yarodevuci Sorry, read your post again, are you using height for row at index path in your project to cater for older iOS versions? I used dynamic layout on the cells and took out the heightforrow, i found that i kept getting a issue on my last chat message wrt sizing, so the cell would always also appear behind the keyboard.

NB: when using autolayout and dynamic sizing, dont forget to set the estimatedRowHeight, then your cells shouldnt appear behind the keyboard anymore.

yarodevuci commented 7 years ago

@adamsrosco I use UITableViewAutomaticDimension height for row. and tableView.estimatedRowHeight = 125 Can you please specify more details how I can use dynamic layout on the cells and dynamic sizing? Funny part that it does not happens every time, it happens randomly. And it's very annoying.

adamsrosco commented 7 years ago

It looks like you are already using autolayout. When you run in the simulator do you get any layout warning messages? That could indicate there's atleast one constraint that may be the cause of that.

yarodevuci commented 7 years ago

@adamsrosco no I don't have any errors when it happens.

screen shot 2017-04-25 at 12 19 02 am

here is the screen of my constraints

adamsrosco commented 7 years ago

mm... I will have to check this again. I do have a project implementing the controller again, and can have a look at it then. Will be about 3 weeks from now though.

out of interest, is there a need for the autocorrect/autosuggest bar to show, i've disabled this in the past so the content size adjusts correctly. I am wondering in the slack controller takes this into account... it might solve your problem in the short term.

yarodevuci commented 7 years ago

@adamsrosco I don't see any autocorrect bar on mine . Cool I can wait, let me know later

yarodevuci commented 7 years ago

@adamsrosco any updates so far?

Smnelson13 commented 7 years ago

@adamsrosco I figured it out, my solution was to create a class that gives CGFloat4 points of cushion around the whole text. that was the easiest way I personally found.

yarodevuci commented 7 years ago

@Smnelson13 Hi, I am totally lost of what you just said. Can you please explain in more details ?

Smnelson13 commented 7 years ago

@yarodevuci Sorry, i was on my phone and tried to summarize it. `class InsetLabel: UILabel { let topInset = CGFloat(4) let bottomInset = CGFloat(4) let leftInset = CGFloat(8) let rightInset = CGFloat(8)

override func drawText(in rect: CGRect) { let insets: UIEdgeInsets = UIEdgeInsets(top: topInset, left: leftInset, bottom: bottomInset, right: rightInset) super.drawText(in: UIEdgeInsetsInsetRect(rect, insets)) }

override public var intrinsicContentSize: CGSize { var intrinsicSuperViewContentSize = super.intrinsicContentSize intrinsicSuperViewContentSize.height += topInset + bottomInset intrinsicSuperViewContentSize.width += leftInset + rightInset return intrinsicSuperViewContentSize } } `

I run my text through this to get the border effect I wanted. UsingCGRect I created insets and inserted them around the text.

yarodevuci commented 7 years ago

@Smnelson13 So basically u hard coded that?, In my case I am using custom UITableViewCell xib

Smnelson13 commented 7 years ago

@yarodevuci I used a xib as well, when I used the xib I still encountered this problem so by doing what i listed above I fixed the issue.

yarodevuci commented 7 years ago

@Smnelson13 So basically you got rid of xib and replaced it via code based? In that case how did you use that class? U manually create a view with text and how u put it in table view?

Smnelson13 commented 7 years ago

@yarodevuci I made the class of the Xib insetLabel if that's what you mean.

yarodevuci commented 7 years ago

@Smnelson13 By any chance do u have a full example of your code?

Smnelson13 commented 7 years ago

@yarodevuci https://github.com/Smnelson13/NotSoCleverBot.git

yarodevuci commented 7 years ago

@Smnelson13 Thank you!! I ll take a look

@Smnelson13 I like your approach a lot! However, I am using label inside view so your method did not helped me. But i am thinking to get rid of the view container and leave just a label

adamsrosco commented 7 years ago

Hi,

our work with the controller has been pushed out. I need to have a look at your code again. How are you setting up your tableview in relation to the input field.

is the table up against the input view, or is the input view over the table?

Regards, Rosco.

yarodevuci commented 7 years ago

@adamsrosco , how do I check that? I am setting it up just like example does, and am using my custom cell xib for messages, that also have bottom label for delivery status.

johndoehelloworld commented 7 years ago

@yarodevuci I see that you were able to use dynamic heights for your custom cell. I'm trying to do the same. I try to do the following in viewDidLoad: tableView.estimatedRowHeight = 44 tableView.rowHeight = UITableViewAutomaticDimension And then this: override func tableView(_: UITableView, heightForRowAt _: IndexPath) -> CGFloat { return UITableViewAutomaticDimension } override func tableView(_: UITableView, estimatedHeightForRowAt _: IndexPath) -> CGFloat { return 44 }

But this renders my label with a height only enough to view 1 line. I have no. of lines on the label set to 0, and I'm seeing no auto-layout constraint issues. I have only the trailing, leading, and top for the said label.

Any idea what might I be missing? Help is much appreciated!

yarodevuci commented 7 years ago

@johndoehelloworld have u set all the constraints like leading trailing , bottom and top?

johndoehelloworld commented 7 years ago

@yarodevuci Yes I did..I can't for the life of me figure out why it isn't working.. Did you do anything non standard to make this work?

yarodevuci commented 7 years ago

@johndoehelloworld can u attach some screenshots of ur constraints and actual tableViewCell ?

johndoehelloworld commented 7 years ago

screenshot 2017-08-01 23 31 30 screenshot 2017-08-01 23 33 31 screenshot 2017-08-01 23 34 39 screenshot 2017-08-01 23 35 50

The second and third sreenshots correspond to the message label that needs to grow vertically to fit content. Thanks for your time!

Smnelson13 commented 7 years ago

If you would like I can send you a Xib file that I use. I'm my newer most up to date project that I'm using this my contains are set to be greater than or = to something. You have your label constrains set but I think it might not be able to grow due to the fact the constrains are set to a exact number. By using greater than or = to you can make a constraint grow and change as need be. Then set lines to 0.

Sent from my iPhone

On Aug 2, 2017, at 2:36 AM, johndoehelloworld notifications@github.com wrote:

The second and third sreenshots corresponds to the message label that needs to grow vertically to fit content. Thanks for your time!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

johndoehelloworld commented 7 years ago

Hi @Smnelson13 – can you please share with me you XIB? Thanks for offering! Are you sure you aren't talking about >= in terms of height? My constraints are about pinning the edges of the label to the sides rather than describe it's height. But again, I might be missing something. Any help is much appreciated. Thanks again!

johndoehelloworld commented 7 years ago

@yarodevuci : Thoughts on my screenshots? Thanks in advance for your time!

johndoehelloworld commented 7 years ago

@Smnelson13 For instance, see this screenshot: I increased the height of the cell in IB, and the label grows.

screenshot 2017-08-02 18 50 24

Smnelson13 commented 7 years ago

What I did is put a label on the left or wright depending on the user. The label has constraints that explicitly set on top and left. The bottom and right side are >= and line set to 0. I can send the xib when I get home to my computer.

Sent from my iPhone

On Aug 2, 2017, at 9:51 PM, johndoehelloworld notifications@github.com wrote:

@Smnelson13 For instance, see this screenshot: I increased the height of the cell in IB, and the label grows.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.