How can I transfer an iPone project to an iPad with multiple Xib files?

Source: Internet
Author: User

MultipleXib FileHow to SetIPoneProjectIPadThe platform is the content to be introduced in this article, mainly to resolve iPone projectIPadIf there are multipleXib FileWhat should I do? Let's take a look at how this article solves the problem.

1. First, the problem cannot be considered as complicated. This conversion is actually very simple.

2. Upgrade the iphone to the universal version.

3. In. plist, there should be the key of main nib file base name, corresponding to MainWindow, which is the entry of the iphone program;

At the same time, there will be the main nib file base name (iPad). If not, you can create one by yourself. The universal version will come out later and select it.) Then you need to create an xib file by yourself, as the iPad portal, for example, MainWindow-iPad

Tip: if you already have an iPhone xib file, open the xib file, and then file => Create iPad version (using autosizing masks) to generate an iPad untile. xib file, and then save it as your own name for iPad xib. Drag and join your project.

The above is to solve the program entry problem.

4. For other xib files, such as AController. xib,

First, use the above techniques to generate a AController-iPad.xib and add it to your project;

Find the class file AController. m,

 
 
  1. - (void)viewDidLoad   
  2. {  
  3. if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)     
  4. {  
  5. [[NSBundlemainBundle] loadNibNamed:@"AController-iPad"owner:selfoptions:nil];  
  6. }  
  7. else  
  8. {  
  9. [[NSBundlemainBundle] loadNibNamed:@"AController"owner:selfoptions:nil];  
  10. }      
  11.  
  12. [superviewDidLoad];  
  13. //your other init code here  

Add the code in the red part, the loadNibNamed: according to the specific change.

5. For other internal code, if the iPhone and iPad versions are different, continue to use the above if judgment statement.

 
 
  1. if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)     
  2. {  
  3. //iPad version code here  
  4. }  
  5. else  
  6. {  
  7. //iPhone/touch version code here  

6. We strongly recommend that you use the size instead of the specific number for the control position and size when writing a program. weight, size. write the statement like height, or open a separate head file to define it out, otherwise it will be very depressing to change the size one by one.

Iphone-> iPad changes are not difficult, but they must be careful.

For the moment, I only think so much. I will try again later.

Summary: there are multipleXib FileHow to SetIPoneProjectIPadThe content of the platform has been introduced. I hope this article will help you!

Related Article

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.