Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. UIAlertController * alertController = [UIAlertController alertControllerWithTitle: @"TODO" message: @"Lägg till en ny TODO" preferredStyle:UIAlertControllerStyleAlert];
  2.  
  3. [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
  4. textField.placeholder = @"Ange vad som ska göras här";
  5. textField.textColor = [UIColor blackColor];
  6. textField.clearButtonMode = UITextFieldViewModeWhileEditing;
  7. textField.borderStyle = UITextBorderStyleRoundedRect;
  8. }];
  9.  
  10. //Button for adding the new TODO
  11. [alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  12.  
  13. NSArray *textfields = alertController.textFields;
  14. UITextField * todo = textfields[0];
  15.  
  16. NSLog(@"%@", todo.text);
  17.  
  18. }]];
  19.  
  20. //Button for cancelling
  21. [alertController addAction:[UIAlertAction actionWithTitle:@"Avbryt" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {}]];
  22.  
  23. [self presentViewController:alertController animated:YES completion:nil];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement