带有Tableview或Scrollview的iPhone UI? [英] iPhone UI with Tableview or Scrollview?

查看:105
本文介绍了带有Tableview或Scrollview的iPhone UI?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道在为特定屏幕构建UI时iOS开发的最佳实践是什么。由于可以为tableviews创建自定义单元格,因此您可以使用tableview来创建您可能想要的任何布局/ UI。这引出了我的问题:

I am wondering what the best practice is in iOS development when it comes to building the UI for a particular screen. Since it is possible to create custom cells for tableviews you can use a tableview to create just about any layout/UI that you could want. Which leads me to my question:

一般情况下,在iPhone应用程序上创建一个屏幕,其内容比单个屏幕上的内容更多,是否更好用滚动视图并将自定义视图加载到滚动视图中,或创建一个tableview并将自定义视图改为自定义tableview单元格?

In general when creating a screen on an iPhone application which will have more content than can fit on a single screen, is it better to use a scrollview and load your custom views into the scrollview, or to create a tableview and have your custom views instead be custom tableview cells?

最后看起来你可以实现完全相同的视觉效果,但最佳做法是什么。如果使用tableview或scrollview构建特定的可滚动屏幕,我很难告诉我已下载的应用程序。

In the end it seems like you can achieve the exact same visual result but what is best practice. It is hard for me to tell on apps that I have downloaded if a particular scrollable screen was built using a tableview or a scrollview.

在HTML中,您应该只使用元素来显示表格数据,而不是用于布局和样式目的。 iOS中的情况是一样的吗?将tableviews用于布局目的是不好的做法(例如,应用程序的主屏幕列出了按钮以转到应用程序的其他部分)?

In HTML you should only use the element for displaying tabular data, not for layout and style purposes. Is it the same case in iOS? Is it poor practice to use tableviews for layout purposes (eg, a home screen of an app which lists buttons to go to other sections of an app)?

提前干杯。

推荐答案

如果你有很多内容要滚动,那么 UITableView 可能会帮助你减少内存使用量。

If you have lots of content to scroll through, a UITableView might help you with keeping memory usage down.

当一个单元格滚出视线时,它会从视图中移除并被保留UITableView 供以后使用(通过 -dequeueReusableCellWithIdentifier:)。如果内存不足,我相信这些不可见的视图( UITableViewCell s)将被释放。这基本上意味着您的应用只会在内存中保留实际可见的视图。更多内容将被缓存,但可以在需要时随时清除。

When a cell scrolls out of sight, it gets removed from the view and kept around by the UITableView for later use (via -dequeueReusableCellWithIdentifier:). If you run low on memory then I believe that those invisible views (UITableViewCells) will get released. This basically means that your app will only keep views in memory that are actually visible. More will be cached, but can be purged any time if needed.

如果您显示大量数据,只需将其全部添加到 UIScrollView 与使用 UITableView 相比,它可能会占用更多内存。您可能必须实现类似于 UITableView 删除(并可能释放)不可见视图的机制。

If you display a lot of data, and just add it all to a UIScrollView it will potentially use much more memory than if you used a UITableView. You might have to implement a similar mechanism to what UITableView does to remove (and potentially release) invisible views.

所以,你基本上可以达到同样的效果,但 UITableView 已经为你做了很多工作。

So, you can basically achieve the same effect, but a UITableView does a lot of that work for you already.

如果您显示大量数据(可能超过两个屏幕已满),我倾向于使用 UITableView

If you display lots of data (probably more than about two screens full) I'd lean towards using a UITableView.

这篇关于带有Tableview或Scrollview的iPhone UI?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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