iOS: 创建universal app
2013-09-18 15:27
281 查看
universal app supports both ipad and iphone。要了解universal如何支持both ipad and iphone,最直接的方法就是创建一个universal project。
universal project的基本特点:
1. target > summary > devices is universal
2. xib for ipad and xib for iphone can share the same view controller,当然使用不同的view controller绝对没问题。
3. in appdelegate.m didFinishLaunchingWithOptions method, use following code to 根据device是ipad还是iphone来指定 access 不同的 view
[cpp] view
plaincopy
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
} else {
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil];
}
<pre name="code" class="cpp"> self.window.rootViewController = self.viewController;</pre> [self.window makeKeyAndVisible];<p></p>
<pre></pre>
<br>
4. 其他class还可以通过<br>
<p></p>
<p></p><pre name="code" class="cpp">[[UIDevice currentDevice] userInterfaceIdiom]</pre>来判断是ipad还是iphone来执行不同的代码<p></p>
<p><br>
</p>
<p><strong><span style="color:#ff0000">如何把iphone app转换成universal app?</span></strong></p>
<p>非常简单,只需要把target > summary > devices option设置为universal即可。当然你要自己创建一组for ipad的ui,并在delegate.m里根据device指定不同的view。</p>
<p><br>
</p>
<p>ref links:</p>
<p><a href="http://richielin-programer.blogspot.com/2010/06/iphone-ipad-universal-app.html">http://richielin-programer.blogspot.com/2010/06/iphone-ipad-universal-app.html</a><br>
</p>
<p><a href="http://iphonedevelopment.blogspot.com/2010/04/converting-iphone-apps-to-universal.html">http://iphonedevelopment.blogspot.com/2010/04/converting-iphone-apps-to-universal.html</a><br>
</p>
<p><br>
</p>
<p><br>
</p>
<div><br>
</div>
universal project的基本特点:
1. target > summary > devices is universal
2. xib for ipad and xib for iphone can share the same view controller,当然使用不同的view controller绝对没问题。
3. in appdelegate.m didFinishLaunchingWithOptions method, use following code to 根据device是ipad还是iphone来指定 access 不同的 view
[cpp] view
plaincopy
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil];
} else {
self.viewController = [[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil];
}
<pre name="code" class="cpp"> self.window.rootViewController = self.viewController;</pre> [self.window makeKeyAndVisible];<p></p>
<pre></pre>
<br>
4. 其他class还可以通过<br>
<p></p>
<p></p><pre name="code" class="cpp">[[UIDevice currentDevice] userInterfaceIdiom]</pre>来判断是ipad还是iphone来执行不同的代码<p></p>
<p><br>
</p>
<p><strong><span style="color:#ff0000">如何把iphone app转换成universal app?</span></strong></p>
<p>非常简单,只需要把target > summary > devices option设置为universal即可。当然你要自己创建一组for ipad的ui,并在delegate.m里根据device指定不同的view。</p>
<p><br>
</p>
<p>ref links:</p>
<p><a href="http://richielin-programer.blogspot.com/2010/06/iphone-ipad-universal-app.html">http://richielin-programer.blogspot.com/2010/06/iphone-ipad-universal-app.html</a><br>
</p>
<p><a href="http://iphonedevelopment.blogspot.com/2010/04/converting-iphone-apps-to-universal.html">http://iphonedevelopment.blogspot.com/2010/04/converting-iphone-apps-to-universal.html</a><br>
</p>
<p><br>
</p>
<p><br>
</p>
<div><br>
</div>
相关文章推荐
- iOS 中创建一个Universal App并且添加多个target
- iOS: 创建universal app
- iOS: 创建universal app
- iOS 创建universal app
- 基于 Hybrid App(混合模式移动应用)中IOS开发证书创建和打包使用
- IOS开发创建开发证书及发布App应用(一)——流程说明
- iOS 10:用 Speech 框架创建語音輸入 App
- iOS 创建一个App目录结构
- 用 JSQMessagesViewController 创建一个 iOS 聊天 App - 第 1 部分
- 如何用 React Native 创建一个iOS APP?
- IOS开发创建开发证书及发布App应用(三)——创建App ID
- 创建Entitlements文件与编译iOS APP
- iOS App创建桌面快捷方式
- iOS 在itunes connect创建App内购项目时遇到的坑
- IOS开发创建开发证书及发布App应用(二)——创建证书
- 如何用 React Native 创建一个iOS APP?(三)
- iOS runloop 创建一个和App生命周期相同的线程
- 用 JSQMessagesViewController 创建一个 iOS 聊天 App - 第 2 部分
- 如何用 React Native 创建一个iOS APP?
- IOS开发创建开发证书及发布App应用(二)——创建证书