iOS Getting Started notes (using date picker)

Source: Internet
Author: User

1. Create a project

Create an initial scene, and a date selection scene (you can set its background color to scroll view Texted Background color), select a date selector to the view

2. Create a toggle

Control the view from the initial viewport to the date, (note the difference from the previous chapter, because it is connected by two controllers, so trigger the switchover manually so that the switch is named for code implementation)

3. Implementing the Logic

1. In the implementation in addition to let two controllers know each other's method properties, but also provide a property (let the date selector can access the initial controller, he will access the initial controller through this property, because in the ipad to prevent users to display multiple pop-up boxes at the same time, If you just use modal switching, you can use Presentingviewcontroller to get the initial scene view controller, but it does not apply to the popup box.

I'm just looking at the iphone here.

2. How to switch manually

Due to manual switching, write code in the method that is pressed by the corresponding conversion button

First, you want to check whether the date selector view is currently displayed, and by setting a Boolean property to judge, add in the initial controller header file

@property (nonatomic) Boolean datechooservisible

Boolean is not an object, so declaring a property without using the keyword strong also does not need to be used to set it to nil,

-(ibaction) Show:id (sender) {

if (self.datachooservisible! = YES)

{

[Self performseguewithidentifier:@ "Todatachooser" sender:sender];//startup identifier Todatachooser conversion, sender is the object that initiates the switchover

self.datachooservisble = Yes;

}

}

When the date selection interface is turned on, only bool changes to Yes must be changed back to no when the interface is closed.

-(void) Viewwilldisappear: (BOOL) animated{//This method occurs when the view is closed

((Viewcontroller *) self.delegate). datechooservisible = NO; The variable bool in the initial view is accessed through the property to change it back to No

}

Close modal scene

-(ibaction) dismiss self-defined close button

{

[Self dismissviewcontrolleranimated:yes completetion:nil];

}

iOS Getting Started notes (using date picker)

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.