简体   繁体   English

iOS:通用应用程序:平台特有的UI对象

[英]iOS: Universal App: UI objects unique to platforms

When converting my iPhone app to universal I needed to create a unique navigation bar for the detail view on the iPad. 将我的iPhone应用程序转换为通用应用程序时,我需要为iPad上的详细信息视图创建一个唯一的导航栏。 The old one featured a button, now I need to replicate the same behavior for the iPad Button, is it possible to do this without copying everything - If possible I´d like to avoid having one property for each and each have their own event handling methods. 旧的有一个按钮,现在我需要为iPad Button复制相同的行为,是否可以在不复制所有内容的情况下做到这一点?方法。

Use the same view controller class files (.m and .h files) for the same view controller for both the iPad and iPhone (separate .xib files, one for iPhone and one for iPad). 将相同的视图控制器类文件(.m和.h文件)用于iPad和iPhone的同一视图控制器(单独的.xib文件,一个用于iPhone,一个用于iPad)。 Be sure that you assign the same Custom Class for the view controller on the Identity Inspector tab in Interface Builder for the new iPad view controller. 确保为新的iPad视图控制器在Interface Builder的Identity Inspector选项卡上为视图控制器分配相同的自定义类。

Using the Assistant Editor in Interface Builder, simply CTRL-drag the button from the new iPad view controller to the existing IBOutlet property in the .h file or existing IBAction method in the .m file. 使用Interface Builder中的助手编辑器,只需将按钮从新的iPad视图控制器中拖动到.h文件中的现有IBOutlet属性或.m文件中的现有IBAction方法即可。

The common approach is to use one .xib file for iPhone and a separate .xib file for iPad. 常见的方法是为iPhone使用一个.xib文件,为iPad使用一个单独的.xib文件。 You can still use the same code for your view controller. 您仍然可以对视图控制器使用相同的代码。 It's also possible to programmatically drive your UI (with no .xib or storyboard). 也可以以编程方式驱动您的UI(没有.xib或情节提要)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM