自定义UISplitViewController? [英] Custom UISplitViewController?

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

问题描述

我想要UISplitViewController的效果,但是我没有使用拆分视图模板.

I want the effect of a UISplitViewController however I am not using the split view template.

没有模板相对容易实现吗?并使用普通的UIViewController?

Is it relatively easy to achieve without the template? And with using normal UIViewController?

我想要的是一个惯用的大小和位置的UITableView,然后它具有惯用的大小的详细视图,然后当肖像时会进入一个弹出框和详细视图.

What I want it a customary sized and positioned UITableView which then has a customary sized detail view which then of course goes into a popover and detail view when portrait.

推荐答案

在不使用Interface Builder的情况下,您将创建一个UIViewController类.在该类的viewDidLoad方法中,创建一个UIView或一个UITableView,并在其中添加所需的帧原点和所需的大小.(在viewDidUnload方法中释放它.)然后将UIViewController的self.view设置为指向此新视图.

Doing it without Interface Builder, you would create a UIViewController class. In the viewDidLoad method of that class, create a UIView or a UITableView with the frame origin where you want it and a size that you want. (Release it in the viewDidUnload method.) Then set the UIViewController's self.view to point to this new view.

self.view = [[UIView alloc] initWithFrame:...];    // edit - added in response to your question

如果创建了UIView,则需要将UITableView放入此新视图中.(此方法可让您根据需要向容器UIView添加更多项目.)

If you created a UIView, then you will want to put your UITableView inside this new view. (This approach lets you add more items to the container UIView if you need to.)

确保您的UIViewController遵守UITableViewDelegate和UITableViewDataSource协议.添加委托和数据源方法,您应该一切顺利.

Make sure your UIViewController adheres to the UITableViewDelegate and UITableViewDataSource protocols. Add the delegate and datasource methods and you should be good to go.

此新视图可以涵盖其他视图,或者您可以调整其他视图的大小以适合其旁边.您只需要根据要使用的框架设置框架即可.

This new view can cover other views, or you can size the other views to fit beside it. You only need to set there frames according to what you want to do with them.

如果使用UITableViewController,则存在一些限制,因此很多人建议使用UIViewController.就像我上面描述的您可以在Google上搜索有关该主题的更多信息.

There are some limitations if you use a UITableViewController, so a lot of people recommend using a UIViewController instead. like I described above. You can google for more info on that topic.

这篇关于自定义UISplitViewController?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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