[TwistedFate]UIAlertView

AlertView

初始化

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"確定刪除?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定", nil];

添加button

[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];

彈窗多與button連用

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 addButtonWithTitle:@"註冊"];
     alert.title = @"hah ";

    //alert.delegate = self;
    [alert setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
    UITextField *text1 = [alert textFieldAtIndex:0];
    UITextField *text2 = [alert textFieldAtIndex:1];
    text1.keyboardType = UIKeyboardTypeNamePhonePad;
    text2.keyboardType = UIKeyboardTypeURL;
    [alert show];
   // [self.window addSubview:alert];
    [alert release];
   // NSLog(@"%d",alert.visible);
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    NSLog(@"%ld",buttonIndex);
}
發佈了68 篇原創文章 · 獲贊 0 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章