First, the effect
Second, the Code implementation
-(void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (Uievent *) event
{
[Self sheetTest1];
}
/**
Note: You cannot add a text box to the pull-down menu
If a text box is forcibly added, a run-time error is reported:
Reason: ' Text fields can-only is added to an alert controller of style Uialertcontrollerstylealert '
*/
/**
* Bottom pull-up menu
*/
-(void) SheetTest1
{
/**
The pull-up menu can be useful when you need to show users a range of choices, and the pull-up menu is displayed in the form of a device size.
1. On iphone (tighten width), pull-up menu rises from bottom of screen
2. On ipad (regular width), the pull-up menu is displayed as a popup box
The way you create a pull-down menu is very similar to the way you create a dialog box, except that the only difference is their form
*/
/**
Note: the "Cancel" button is always at the bottom of the pull-down menu
The IOS user interface Guide requires that all "destroy" style buttons must be ranked first and red.
*/
1. Create a View Controller
Uialertcontroller *alertcontroller = [Uialertcontroller
alertcontrollerwithtitle:@ "Save or delete data"
message:@ "Delete data will not be recoverable"
Preferredstyle:uialertcontrollerstyleactionsheet];
2. Add a button
Uialertaction *cancelaction = [uialertaction
actionwithtitle:@ "Cancel"
Style:uialertactionstylecancel
Handler:nil];
Uialertaction *deleteaction = [uialertaction
actionwithtitle:@ "Delete"
Style:uialertactionstyledestructive
Handler:nil];
Uialertaction *archiveaction = [uialertaction
actionwithtitle:@ "Save"
Style:uialertactionstyledefault
Handler:nil];
3. Add a button to the view controller
[Alertcontroller addaction:cancelaction];
[Alertcontroller addaction:deleteaction];
[Alertcontroller addaction:archiveaction];
4. Display View Controller
[Self Presentviewcontroller:alertcontroller animated:yes completion:nil];
}
Uialertcontroller class--sheet Pull-up menu 1 (Basic)