Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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. :(

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
199 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...