SlackTextViewController icon indicating copy to clipboard operation
SlackTextViewController copied to clipboard

Message bubble is behind keyboard.

Open yarodevuci opened this issue 7 years ago • 35 comments

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

yarodevuci avatar Mar 07 '17 07:03 yarodevuci

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?

adamsrosco avatar Mar 13 '17 11:03 adamsrosco

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

yarodevuci avatar Mar 13 '17 14:03 yarodevuci

@adamsrosco or @dzenbot Any word on that?

yarodevuci avatar Apr 08 '17 05:04 yarodevuci

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

Smnelson13 avatar Apr 24 '17 16:04 Smnelson13

@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 avatar Apr 25 '17 05:04 adamsrosco

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

adamsrosco avatar Apr 25 '17 05:04 adamsrosco

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

adamsrosco avatar Apr 25 '17 05:04 adamsrosco

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

yarodevuci avatar Apr 25 '17 06:04 yarodevuci

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.

adamsrosco avatar Apr 25 '17 07:04 adamsrosco

@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

yarodevuci avatar Apr 25 '17 07:04 yarodevuci

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.

adamsrosco avatar Apr 25 '17 07:04 adamsrosco

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

yarodevuci avatar Apr 25 '17 07:04 yarodevuci

@adamsrosco any updates so far?

yarodevuci avatar Jun 07 '17 06:06 yarodevuci

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

Smnelson13 avatar Jun 08 '17 01:06 Smnelson13

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

yarodevuci avatar Jun 08 '17 02:06 yarodevuci

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

Smnelson13 avatar Jun 08 '17 02:06 Smnelson13

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

yarodevuci avatar Jun 08 '17 02:06 yarodevuci

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

Smnelson13 avatar Jun 08 '17 02:06 Smnelson13

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

yarodevuci avatar Jun 08 '17 02:06 yarodevuci

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

Smnelson13 avatar Jun 08 '17 02:06 Smnelson13

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

yarodevuci avatar Jun 08 '17 03:06 yarodevuci

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

Smnelson13 avatar Jun 08 '17 03:06 Smnelson13

@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

yarodevuci avatar Jun 08 '17 03:06 yarodevuci

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.

adamsrosco avatar Jun 09 '17 13:06 adamsrosco

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

yarodevuci avatar Jun 11 '17 08:06 yarodevuci

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

johndoehelloworld avatar Aug 02 '17 04:08 johndoehelloworld

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

yarodevuci avatar Aug 02 '17 04:08 yarodevuci

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

johndoehelloworld avatar Aug 02 '17 05:08 johndoehelloworld

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

yarodevuci avatar Aug 02 '17 05:08 yarodevuci

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!

johndoehelloworld avatar Aug 02 '17 06:08 johndoehelloworld