AlertView
初始化
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"確定刪除?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil];
[alert addButtonWithTitle:@"註冊"]
修改標題
alert.title = @"通知"
在彈窗中添加TextField
[alert setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
UITextField *text1 = [alert textFieldAtIndex:0];
UITextField *text2 = [alert textFieldAtIndex:1];
text1.keyboardType = UIKeyboardTypeNamePhonePad;
text2.keyboardType = UIKeyboardTypeURL;
顯現 彈窗alert
[alert show];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(100, 100, 100, 50);
button.backgroundColor = [UIColor redColor];
[button setTitle:@"打開" forState:UIControlStateNormal];
[button addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
[self.window addSubview:button];
- (IBAction)buttonPressed:(UIButton *)button{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"確定刪除?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil];
alert.title = @"hah ";
[alert setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
UITextField *text1 = [alert textFieldAtIndex:0];
UITextField *text2 = [alert textFieldAtIndex:1];
text1.keyboardType = UIKeyboardTypeNamePhonePad;
text2.keyboardType = UIKeyboardTypeURL;
[alert show];
[alert release];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@"%ld",buttonIndex);
}