创建一个坚持UITableView底部的UIView [英] Creating a UIView that sticks to bottom of UITableView

查看:119
本文介绍了创建一个坚持UITableView底部的UIView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个分组的UITableView ,我想在我的 UITableView 的最底部添加一个UIButton 。我正在使用Storyboard和UITableViewController。我不太确定我需要添加代码或拖放UI元素。我已经尝试在Storyboard中添加一个UIView作为footerview,然后在该视图中添加一个按钮,但这并不具有始终保持在视图底部的预期效果,类似于tabbar。此外,按钮应该始终保持在最前面,UITableView应该在它后面滚动。

I have a grouped UITableView and I'd like to add a UIButton to the very bottom of my UITableView. I'm using Storyboard and a UITableViewController. I'm not quite sure where I need to add code or drag/drop UI Elements. I've tried adding a UIView as the footerview in Storyboard and then adding a button to that view, but this doesn't have the desired effect of always staying on the very bottom of the view, similar to a tabbar. Also, the button should always stay in the forefront, and the UITableView should scroll behind it.

// tried this but it didn't work:
self.tablview.tableFooterView = [[UIView alloc] initwithview...]


推荐答案

如果您希望 UIButton 位于屏幕底部,无论<$ c $的滚动位置如何c> UITableView (即,不在 UITableView 内),那么你可能不应该使用 UITableViewController 子类。相反,如果您使用 UIViewController 子类,您只需将 UITableView 添加到您的根查看属性并添加 UIButton 或其他一些视图(例如 UIToolbar 等)具有适当的布局约束,将其放置在屏幕的底部 - 或者您想要的位置。对于 UITableViewController 子类,这是不可能的,因为根视图属性必须是 UITableView 实例。

If you want your UIButton to be at the bottom of the screen regardless of the scroll position of the UITableView (i.e., not inside the UITableView) then you should probably not use a UITableViewController subclass. Instead, if you use a UIViewController subclass, you can simply add a UITableView to your root view property and add a UIButton or some other view (such as a UIToolbar, etc) with appropriate layout constraints to place it at the bottom of the screen - or wherever you want it. This is not really possible with a UITableViewController subclass, as the root view property is required to be a UITableView instance.

这篇关于创建一个坚持UITableView底部的UIView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆