iOS等同于Android Fragments / Layouts [英] iOS equivalent to Android Fragments/Layouts

查看:118
本文介绍了iOS等同于Android Fragments / Layouts的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android中,您可以使用Fragments仅开发一个针对手机和表格的应用程式,因此您可以有不同的使用者介面。您甚至可以只使用布局,并在代码上运行平板电脑或手机逻辑。

In Android you can use Fragments to develop only one app targeted to phones and tables, so you can have different UI. You can even use only Layouts and have some condition on the code to run tablet or phone logic.

我需要为iPhone和iPad开发一个应用程序,我想知道是否是类似的实现不同的UI和轻微不同的行为。在我的情况下,iPhone应用程序将使用屏幕底部的标签,但iPad应该使用左侧的菜单。

I need to develop an app for iPhone and iPad and I wonder if there is something similar for implementing different UIs and slighty different behavior. In my case the iPhone app would use tabs at the bottom of the screen, but the iPad one should use the menu on the left side.

推荐答案

是的,您可以为iPhone和iPad使用不同的UI。
创建两个 XIB 文件,当在屏幕上显示它们时,使用此条件启动 XIB p>

Yes you can use Different UI for iPhone and iPad. Create Two XIB files and when showing them on the screen use this condition to initiate the XIB

UIViewController *viewController;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
    viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease];
} else {
    viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil] autorelease];
}
[self.navigationController pushViewController:viewController animated:YES];

这篇关于iOS等同于Android Fragments / Layouts的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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