Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (void)mySuperMethodWithAlert
- {
- // ... bla bla bla
- // создаем и показывем UIAlertView
- //
- UIAlertView *alertView = [[UIAlertView alloc] initWithTitle: @"Who are you?"
- message:@"Give your full name"
- delegate:self cancelButtonTitle:@"Cancel"
- otherButtonTitles:@"OK", nil];
- // Adds a username Field
- //
- UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 50.0, 260.0, 25.0)];
- textField.placeholder = @"Username";
- [textField setBackgroundColor:[UIColor whiteColor]];
- [alertView addSubview:textField];
- [alertView show];
- [alertView release];
- [textField release];
- // ... bla bla bla
- }
- // Обрабатываем нажатие кнопки
- //
- - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
- // the user clicked one of the OK/Cancel buttons
- if (buttonIndex == 0)
- {
- UITextField *field = (UITextField *)[[alertView subviews] lastObject];
- NSLog (@"%@", field.text);
- }
- else
- {
- //NSLog(@"cancel");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement