-2

I have a to implement something similar to a chat.

So I thought I will add a scrollview then a table view then a view for textfield and send button then on top of it a tableview.

I also have a tabbar on bottom

Is this the right approach. I also wanted to bring the keyboard up and move the text box upwards

enter image description here

enter image description here

The images is not containing a scroll view because when ever i put a scroll view its screws me up

Additionally I also want to know how to increase the size of the rows depending on the chat message. just a crude drawing enter image description here

this is what I have achieved so far enter image description here enter image description here

I am not able to increase the size of the label according to the data, nor I am able to bring the textfield up when the keyboard is showing. :(

vinbhai4u
  • 1,329
  • 3
  • 19
  • 36

2 Answers2

0

UITableView already inherits from, and contains a UIScrollView so you don't need to add a scroll view yourself, and it would probably cause problems, as I assume is the case from what you have described.

To have the cells adjust automatically, I would check out this tutorial https://www.captechconsulting.com/blogs/ios-8-tutorial-series-auto-sizing-table-cells. It provides lots of details on how and why it works.

For the message bar on the bottom, the way I've done it in the past, is to add the view with the text field and send button to a view (I'll call it the message view) the main view stuck to the bottom, then also set that message view as the input accessory on the text field, so when the text field starts editing, the view will be snapped to the top of the keyboard automatically. I can't quite tell how you have constrained the message view in your picture, but make sure that the bottom of the table view is not constrained to the top of the message view. You want the message view to be floating on top, then the table view can either be constrained the height of the message view from the bottom, or you can set the content inset to push content above the message view.

esthepiking
  • 1,647
  • 1
  • 16
  • 27
0

Finally I got my answer, here is my set up and my output. Thanks to @Isuru for his answer in Move textfield when keyboard appears swift and @esthepiking for helping me out

enter image description here enter image description here enter image description here

Community
  • 1
  • 1
vinbhai4u
  • 1,329
  • 3
  • 19
  • 36