简体   繁体   中英

View with uitableview, tabbar and more objects

I'm developing an app and I need a view with these elements: - UITableView - UITextField and UIButton - TabBar

As you can guess, I am developing a chat, but when I put the elements in the .xib, I can't show de layer: UITextField and UIButton. If I put them without a view, they dont appear. If I put a view under the table, and in that view I put the text and the button I get this error: http://pastebin.com/CKfxijz9 (I put the error there because it's to long)

Thanks in advance

There are some ways of dealing with that, depending on how it should behave. Some of them are:

  1. Provide a table footer or header view that holds the button and the text field.
  2. Nest the table view into another view. The table view and the view containing the button and text fielt are on the same level within the view hierarchy. They are rather siblings than sub- and superview to each other.
  3. Use a UISlider instead of a table. (However, I personally would use the table.)

Here's an approach I've used in the past (not sure if it's best practice, but it works).

  1. Add your button and textfield to a new view (let's call it, bottomView)
  2. Add bottomView to the superview of your tableview
  3. Set the frame of your bottom view so that it fits to the bottom of the screen (this will make it so your tableview will scroll, but keep your bottomView always attached to the bottom of your mainview)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM