ipad Development (Universal applications)

Source: Internet
Author: User

First, the IPad

1, determine whether on the ipad

BOOL IPad = ([[Uidevice currentdevice] userinterfaceidiom] = = Uiuserinterfaceidiompad);

Second, Uisplitviewcontroller split view Controller

1. Uisplitviewcontroller Split View controller (top view, cannot be placed in Nav or other view)

(1 can be judged by if (Self.splitviewcontroller) whether it is in Split view

@property (strong) Uisplitviewcontroller *splitviewcontroller;

(2 controller is divided into two parts, 0 for Master, 1 refers to Detail

@property (copy) Nsarray *viewcontrollers;

For example Uiviewcontroller *DETAILVC = self.splitviewcontroller.viewcontrollers[1]; If we are in the split view, it will return detail, otherwise it will return nil, which can also be used to determine whether the split view

2, delegate agreement (need to define a protocol before viewdidload, may be in awakefromnib)

(1 is primarily used to control when master and detail appear

(2 for example

-(BOOL) Splitviewcontroller: (Uisplitviewcontroller *) sender Shouldhideviewcontroller: (Uiviewcontroller *) Master Inorientation: (uiinterfaceorientation) orientation

{
return NO; Never hide the left master

}

-(BOOL) Splitviewcontroller: (Uisplitviewcontroller *) sender Shouldhideviewcontroller: (Uiviewcontroller *) Master Inorientation: (uiinterfaceorientation) orientation

{

return uiinterfaceorientationisportrait (orientation);//Hide master only in vertical screen (the upper left corner of the corresponding detail will have a button to switch back, But without the implementation of the Trust agreement, there is no such button.

}

-(void) Splitviewcontroller: (Uisplitviewcontroller *) sender Willhideviewcontroller: (Uiviewcontroller *) Master Withbarbuttonitem: (Uibarbuttonitem *) Barbuttonitem Forpopovercontroller: (Uipopovercontroller *) popover

{

Barbuttonitem.title = Master.title;

Self.navigationItem.leftBarButton = barbuttonitem;//is equivalent to setting the button that returns master to Uinavigationcontroller Barbuttonitem

}

3. How does the click in master respond in detail?

(1 through action, as with Preparesegue

-(Ibaction) doit

{

ID detailviewcontroller = self.splitviewcontroller.viewcontrollers[1];

[Detailviewcontroller setsomeproperty: ...];

}

(2 segue: But it will update the entire view controller, including the above-mentioned Navigtionitem buttons we set, will be reset, so it is generally not used

Three, popovers window controller

(not belonging to Uiviewcontroller, is a nsobject, main control another view controller pops to the screen)

1. Get the view controller to eject

@property (nonatomic, strong) Uiviewcontroller *contentviewcontroller; By first getting this view controller to eject

2. Create a popovers Segue

(It is important to note that the segue you get in Prepaeforsegue is a uistoryboardpopoversegue)

1-(void) Prepareforsegue: (Uistoryboardsegue *) Segue Sender: (ID) sender2 {3     if ([Segue iskindofclass:[ Uistoryboardpopoversegue class]] {4         uipopovercontroller *popovercontroller =5             ((Uistoryboardpopoversegue * ) segue). Popovercontroller;6 ... 7}}

3, click outside the Popovers, is generally hidden by default, but if it is the window controller in this view array view, it will not disappear hidden

@property (copy) Nsarray *passthroughviews;

But we can make it hide:

-(void) dismisspopoveranimated: (BOOL) animated;

-(void) Popovercontrollerdiddismisspopover: (Uipopovercontroller *) sender;

ipad Development (Universal applications)

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.