Created
September 22, 2015 06:15
-
-
Save wisaruthk/0f6d02c09a6acaa44e55 to your computer and use it in GitHub Desktop.
ตัวอย่างการใช้ UIAlertController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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