Skip to content

Instantly share code, notes, and snippets.

@wisaruthk
Created September 22, 2015 06:15
Show Gist options
  • Save wisaruthk/0f6d02c09a6acaa44e55 to your computer and use it in GitHub Desktop.
Save wisaruthk/0f6d02c09a6acaa44e55 to your computer and use it in GitHub Desktop.
ตัวอย่างการใช้ UIAlertController
FDPGroup *group = self.datasource[indexPath.row];
UIAlertController* alert = [UIAlertController alertControllerWithTitle:LocalizedString(@"Rename Group")
message:LocalizedString(@"Input Group Name")
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:LocalizedString(@"Cancel")
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
[[self.tableView cellForRowAtIndexPath:indexPath] setSelected:false];
}];
UIAlertAction* renameAction = [UIAlertAction actionWithTitle:LocalizedString(@"Rename")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
FDPFormulaGroup *group = self.formulaGroups[indexPath.row];
UITextField *newGroupName = alert.textFields[0];
group.groupName = newGroupName.text;
[[FDPFormulaGroupStore sharedStore] renameGroup:group.idFmGrp toName:group.groupName];
[self.tableView reloadData];
}];
[alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {
textField.text = group.groupName;
textField.clearButtonMode = UITextFieldViewModeWhileEditing;
}];
[alert addAction:cancelAction];
[alert addAction:renameAction];
[self presentViewController:alert animated:YES completion:nil];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment