1. Create a warning window using Uialertcontroller in IOS8
#pragma mark-a warning window that can be used only in IOS8
-(void) Showokaycancelalert
{
NSString *title = nslocalizedstring (@ "Modify group name", nil);
NSString *message = nslocalizedstring (@ "Please enter a new group name", nil);
NSString *cancelbuttontitle = nslocalizedstring (@ "Cancel", nil);
NSString *otherbuttontitle = nslocalizedstring (@ "OK", nil);
Uialertcontroller *alertcontroller = [Uialertcontroller alertcontrollerwithtitle:title message:message Preferredstyle:uialertcontrollerstylealert];
[Alertcontroller addtextfieldwithconfigurationhandler:^ (Uitextfield *textfield)
{
Textfield.backgroundcolor = [Uicolor Lighttextcolor]; TextField can be customized here, such as changing the background color
}];
Uialertaction *cancelaction = [Uialertaction actionwithtitle:cancelbuttontitle style:uialertactionstylecancel handler:^ (Uialertaction *action) {
NSLog (@ "%s------%d-----Click Cancel Button", __function__, __line__);
}];
[Alertcontroller addaction:cancelaction];
Uialertaction *otheraction = [uialertaction actionwithtitle:otherbuttontitle style:uialertactionstyledefault Handler : ^ (uialertaction *action) {
Uitextfield *textfield = alertcontroller.textfields[0]; Gets the new group name in the input box
if (TextField.text.length = = 0)
{
[[[Uialertview alloc] initwithtitle:@ "Prompt" message:@ "Your new group name is unreasonable" Delegate:nil cancelbuttontitle:@ "OK" Otherbuttontitles:nil, nil] show];
Return
}
NSLog (@ "%s------%d-----Click OK button-----textfield.text =%@", __function__, __line__, Textfield.text);
[[Singleclient Sharedinstanceclient] clientaltergroupinfor: (int) Self.curGroup.g_02_gid Gname:textField.text]; Send a request to the server to modify the group name
}];
[Alertcontroller addaction:otheraction];
[Self Presentviewcontroller:alertcontroller animated:yes completion:nil];
}
Use Uialertcontroller to create a warning window in IOS learning Note nine (2015.04.02) IOS8