UITableView和始终可见的UITextField [英] UITableView and a UITextField that is always visible

查看:60
本文介绍了UITableView和始终可见的UITextField的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个结合了聊天功能的应用程序.我的问题是:我如何拥有一个始终在与UITableView相同的视图中可见的UITextField?

I want to create an application which combines a chat feature. My question is this: how can I have a UITextField that is always visible in the same view as a UITableView?

一个明显的解决方案是创建自己的UIView,并在其下面有一个UITableView和一个UITextField,但是UITableViewController似乎不喜欢我这样做,因为它期望连接的视图"出口是一个UITableView,实质上破坏了我的计划.

The obvious solution would be to create my own UIView having a UITableView and a UITextField below it, however the UITableViewController doesn't seem to like me doing that as it expects the connected "view" outlet to be a UITableView, essentially destroying my plans.

有人有主意吗?

推荐答案

不要使用UITableViewController.毕竟,它只是具有全屏UITableView的标准控制器.您可以轻松地自己滚动.

Don't use UITableViewController. After all, it's just a standard controller with a full-screen UITableView. You can roll your own easily.

使用标准的UIViewController并使其实现UITableViewDelegate和UITableViewDataSource协议(您无需实现所有方法,只需实现所需的方法即可).然后,给它一个UITableView作为iVar,并将委托和dataSource设置为self.调整大小,使其仅占据屏幕的一半,而其他视图占据另一部分.您可以在IB中布置整个内容,也可以手动创建和定位view + table.

Use a standard UIViewController and have it implement UITableViewDelegate and UITableViewDataSource protocols (you don't need to implement every method -- just the required ones). Then give it a UITableView as an iVar and set the delegate and dataSource to self. Size it so it only takes half the screen and your other views take the other part. You can lay out the whole thing in IB or create and position view+table manually.

这篇关于UITableView和始终可见的UITextField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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