IOS7下,alertView不能使用addSubview添加textField解决办法

UIAlertView *alertView1 = [[UIAlertView alloc] initWithTitle:@"Enter Form Name" 
                                               message:@""
                                               delegate:self 
                                               cancelButtonTitle:@"Cancel"
                                               otherButtonTitles:@"Ok", nil];
alertView1.alertViewStyle = UIAlertViewStyleSecureTextInput;
UITextField *myTextField = [alertView1 textFieldAtIndex:0];
[alertView1 setTag:555];
myTextField.keyboardType=UIKeyboardTypeAlphabet;

[alertView1 show];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(180, 10, 85, 50)];
UIImage *wonImage = [UIImage imageNamed:@"image.png"];
[imageView setImage:wonImage];

//check if os version is 7 or above
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
      [alertView setValue:imageView forKey:@"accessoryView"];
}else{
      [alertView addSubview:imageView];
}

 

 
posted @ 2014-09-09 13:30  糊涂人  阅读(392)  评论(0编辑  收藏  举报