简体   繁体   English

使用uitableview,tabbar和更多对象查看

[英]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 我正在开发一个应用程序,我需要一个包含以下元素的视图: - UITableView - UITextField和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. 你可以猜到,我正在开发一个聊天,但当我把元素放在.xib中时,我无法显示de layer:UITextField和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) 如果我把一个视图放在桌子下面,并在那个视图中我把文本和按钮我得到这个错误: http//pastebin.com/CKfxijz9 (我把错误放在那里,因为它很长)

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. 表视图和包含按钮和文本fielt的视图位于视图层次结构中的同一级别。 They are rather siblings than sub- and superview to each other. 他们是兄弟姐妹而不是彼此的次级和超级视角。
  3. Use a UISlider instead of a table. 使用UISlider而不是表。 (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) 将您的按钮和文本字段添加到新视图(让我们调用它,bottomView)
  2. Add bottomView to the superview of your tableview 将bottomView添加到tableview的superview
  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) 设置底部视图的框架,使其适合屏幕的底部(这将使您的tableview将滚动,但保持bottomView始终附加到主视图的底部)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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