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)