universal app supports both ipad and iphone。要了解universal如何支持both ipad and iphone,最直接的方法就是建立一个universal project。html
universal project的基本特色:app
1. target > summary > devices is universaliphone

2. xib for ipad and xib for iphone can share the same view controller,固然使用不一样的view controller绝对没问题。oop
3. in appdelegate.m didFinishLaunchingWithOptions method, use following code to 根据device是ipad仍是iphone来指定 access 不一样的 viewui
- 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>