Programming on iPad and programming software on ipad

Source: Internet
Author: User

Programming on iPad and programming software on ipad

1. iPad

Existing model:

IPad Pro, iPad Air, and iPad mini are equipped with a Retina display. Early iPad

Coordinate System and resolution:

IPad Pro Coordinate System: 1366x1024 resolution: 2732x2048

IPad Air Coordinate System: 1024x768 resolution: 2048x1536

IPad mini Coordinate System: 1024x768 resolution: 2048x1536

 

During development, only 2048x1536 resolution can be designed for images. You can also select the 1024x1536 resolution based on the actual situation.

2. Differences between programming for iPad and iPhone

> Different screen sizes/resolutions

IPhone: 640x960,640x1136 ......

IPad: 2048x1536

> UI element Layout

The iPad screen is larger than that of the iPhone and can contain more UI elements. The arrangement of the two elements is slightly different.

For example, the UITabBarController for iPhone can also be used under the iPad, but generally considering the user experience, it does not display the bar menu at the bottom of the page, instead, the vertical bar menu is displayed on the left. To achieve this effect, you need to use a third-party library (of course, You can encapsulate it yourself ).

[Extension] third-party library implements the vertical bar controller FSVerticalTabBarController

Https://github.com/futuresimple/FSVerticalTabBarController

This library implements a sharding effect similar to iOS native UITabBarController, which is only vertical.

[* Extension *] for the bar Controller under the iPhone, to display tabBarItem of irregular size, you need to customize the implementation. For example, the size of a column is larger than that of other columns, especially in the middle.

For details, see http://code4app.com/ios/tabbar/51886eee6803faf053000003.

> Keyboard

An exit button is added to the lower right corner of the iPad virtual keyboard.

> Unique iPad class

UIPopoverController

UISplitViewController master-slave View Controller [from iOS8, this type can also be used in iPhone applications]

> Differences in some common APIs

The display effects of the same category on the iPhone and iPad are slightly different, but most of them are consistent.

> Screen orientation support

After creating a project, you can view in info. plist to find that the iPhone supports three directions, while the iPad supports four directions.

> Horizontal and vertical screen support suggestions

In general, the iPhone application supports a screen direction, vertical screen or horizontal screen.

It is recommended that the iPad application support horizontal screen and vertical screen, which is also officially recommended. But it is not mandatory. Select based on actual development business needs.

> Select a project running Device

When creating a project, the Device has three values:

All Universal iPhone and iPad can run

IPhone

IPad

If you select the iPhone, you still need to consider whether it works properly on the iPad. One of Apple's official review rules: Apps running on the iPhone must also run properly on the iPad. Generally, select Universal.

If the application only runs on the iPad, select iPad.

> Development Process

The development process for the iPhone and iPad is the same. All the knowledge learned on the iPhone can be applied to the iPad.

3. UISplitViewController

Master-detail container View Controller. In this interface, changes on the master View Controller will drive changes to the content of the controller. The two view controllers are displayed in parallel. It is often used in iPad applications and is generally used as the Root View Controller rootViewController of window. This type can also be used in iPhone applications since iOS8.

Code-only implementation:

Note: After deleting the Main. storyboard file, you need to delete the Main storyboard file base name item in info. plist. Otherwise, the program crashes and an error is reported, prompting that the Main... cannot be found ....

> Initialization

[[UISplitViewController alloc] init]

> Set the master and slave view controllers.

SplitViewController. viewControllers = @ [masterViewController, detailViewController];

This attribute contains two view controllers. The first is the master View Controller, and the second is the detailed/Slave View Controller.

> Set the display mode.

SplitViewController. preferredDisplayMode

The value is as follows:

UISplitViewControllerDisplayModeAutomatic, // automatic mode. You can determine the proper display mode based on the device size,

UISplitViewControllerDisplayModePrimaryHidden, // hide the master View Controller

UISplitViewControllerDisplayModeAllVisible, // The master node is displayed in parallel from the View Controller.

UISplitViewControllerDisplayModePrimaryOverlay // the controller of the master view overwrites the controller of the slave view.

Get Display Mode

SplitViewController. displayMode // note that only the last three of the above four values can be obtained

> Set the display size ratio of the master View Controller.

SplitViewController. preferredPrimaryColumnWidthFraction // note that the value range of this attribute is 0.0 ~ 1.0, for example, 0.2 indicates that the display proportion of the master View Controller in splitViewController is 20%.

Obtain the display size (points) of the master View Controller)

SplitViewController. primaryColumnWidth

> Display the specified slave View Controller, which is usually triggered after the master View Controller is clicked.

[SplitViewController showDetailViewController: sender:]

Parameter 1 indicates the slave View Controller to be displayed, and parameter 2 indicates the view or view controller that generates this request.

> Display the specified master View Controller

[SplitViewController showViewController: sender:]

Parameter 1 indicates the master View Controller to be displayed, and parameter 2 indicates the object request to display

> Sets whether to display or hide a hidden View Controller with a swipe gesture.

SplitViewController. presentsWithGesture

Note that the value is valid only when the View Controller is hidden.

4. UIPopoverController

The Controller is displayed in a floating box mode to display the content of a view controller.

This type of self-iOS9 is discarded, and the effect of popover is achieved through the View Controller modal jump mode. The modal presentation style of the specified view controller is UIModalPresentationPopover, and is configured with the relevant attributes of UIPopoverPresentationController.

-Popover implementation before iOS9: Use of UIPopoverController

> Prepare the Controller for the pop-up view and initialize UIPopoverController

[[UIPopoverController alloc] initWithContentViewController:]

> Display in a specific area

[PopoverController presentpoverfromrect: inView: permittedArrowDirections ctions: animated:];

Parameter 1: The range of the specified Rectangular Box (pointed by the arrow), with the coordinate origin in the upper left corner of the view parameter 2

Parameter 2: The relative view of the coordinate origin of parameter 1

Parameter 3: Arrow direction: determines the direction of the pop-up view. If there is not enough space in the specified direction, the size of the pop-up view is invalid.

Parameter 4: whether to display the animation

The effects of parameters 1 and 2 are as follows:

If you want to display the popover effect after clicking the buttons on the left or right of the navigation bar in the navigation bar view, you can use the following methods:

[PopoverController presentpoverfrombarbuttonitem: permittedArrowDirections ctions: animated:]

> Set the background color (preferably the same as the background color of the pop-up content, which is white by default)

PopoverController. backgroundColor

> Set the size of the pop-up content

[PopoverController setpovercontentsize:];

* ** However, it is generally not recommended to set the size of the pop-up view. The size should be determined by the content view. The preferredContentSize attribute should be set in the controller of the pop-up view.

-IOS9 popover implementation:

> Prepare the Controller for the pop-up view and set its mode pop-up mode.

ContentVC. modalPresentationStyle = uimodalpresentationpover; // specify the style of the modal pop-up window.

[Extension supplement] contentVC. modalTransitionStyle // animation displayed in the modal window

> Set the pop-up attribute of the pop-up view controller.

// Relative view of the coordinate origin of the area indicated by the arrow

ContentVC. popoverPresentationController. sourceView = self. view;

// Area size indicated by the arrow

ContentVC. popoverPresentationController. sourceRect = uv. frame;

// The background color of the view is displayed.

ContentVC. popoverPresentationController. backgroundColor = [UIColor redColor];

// Arrow direction

ContentVC. popoverPresentationController. permittedArrowDirections ctions = UIPopoverArrowDirectionUp;

// Pop-up view in modal Mode

[Self presentViewController: contentVC animated: YES completion: nil];

 

 

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.