IOS: Create Universal App

Source: Internet
Author: User

Universal app supports both ipad and iphone. The most straightforward way to understand how universal supports both ipad and iphone is to create a universal project.

Universal basic features of project:

1. Target > Summary > Devices is universal

2. Xib for ipad and xib for iphone can share the same view controller, of course using a different view controller absolutely no problem.

3. In the APPDELEGATE.M Didfinishlaunchingwithoptions method, use following code to specify access different view depending on whether the device is an ipad or an iphone

[CPP]View Plaincopy
  1. Self.window = [[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];
  2. if ([[Uidevice currentdevice] userinterfaceidiom] = = Uiuserinterfaceidiomphone) {
  3. Self.viewcontroller = [[Viewcontroller alloc] initwithnibname:@"Viewcontroller_iphone" bundle:nil];
  4. } Else {
  5. Self.viewcontroller = [[Viewcontroller alloc] initwithnibname:@"Viewcontroller_ipad" bundle:nil];
  6. }
  7. <pre name="code" class="cpp" > Self.window.rootViewController = self.viewcontroller;</pre> [ Self.window makekeyandvisible];<p></p>
  8. <pre></pre>
  9. <br>
  10. 4. Other class can also be <br>
  11. <p></p>
  12. <p></p><pre name="code" class="cpp" >[[uidevice Currentdevice] Userinterfaceidiom] </pre> to determine whether it's an ipad or an iphone to perform different codes <p></p>
  13. <p><br>
  14. </p>
  15. <p><strong><span style="color: #ff0000" > How to convert iphone app to Universal app? </span></strong></p>
  16. <p> is very simple, just set the target > Summary > Devices option to Universal. Of course you have to create your own set of UI for the ipad and specify a different view based on the device in the DELEGATE.M. </p>
  17. <p><br>
  18. </p>
  19. <p>ref links:</p>
  20. <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>
  21. </p>
  22. <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 >
  23. </p>
  24. <p><br>
  25. </p>
  26. <p><br>
  27. </p>
  28. <div><br>
  29. </div>

IOS: Create Universal App

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.