UIAlertView

来源:互联网 发布:java可变参数写法 编辑:程序博客网 时间:2024/05/16 15:33

UIAlertView  *alert = [[UIAlertView alloc]initWithTitle:@"password"

message:@"please enter your password:"

delegate:self

cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];

    
    alert.alertViewStyle = UIAlertViewStyleLoginAndPasswordInput;
    

    [alert show];


UIAlertView 的属性alertViewStyle

ypedef enum {
UIAlertViewStyleDefault = 0,UIAlertViewStyleSecureTextInput,UIAlertViewStylePlainTextInput,UIAlertViewStyleLoginAndPasswordInput} UIAlertViewStyle;

若类实现UIAlertViewDelegate协议

为此需要实现alertView:clickedButtonAtIndex方法:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

self.result.text = [NSString stringWithFormat:@"You selected: '%@'",[alertView buttonTitleAtIndex:buttonIndex]];
}
- (IBAction)buttonPress:(id)sender {
if (sender == self.button1) {
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Error"   message:@"Unable to reach server" delegate:nil        cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
      [alert show];
} else if (sender == self.button2) {

UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Submit Score"message:@"We'd like to submit your high score to the global scoreboard"
[alert show]; }
}




0 0
原创粉丝点击