我使用以下代码创建了一个UIAlertView
并在其上添加了一些组件,但结果在图像上:(((图像在这里:http: //i.stack.imgur.com/DTg02.png)
-(IBAction)login:(id)sender
{
UIAlertView *login = [[UIAlertView alloc]initWithTitle: @"Login first"
message:@"enter username and password please first" delegate:self cancelButtonTitle:@"cancel"otherButtonTitles:@"OK", nil];
k = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 70.0, 200.0, 25.0)]; //<< it also displays wrong without this line
k.text = @"";
k.backgroundColor = [UIColor whiteColor];
k.clearButtonMode= UITextFieldViewModeWhileEditing;
k.keyboardType = UIKeyboardTypeAlphabet;
k.keyboardAppearance = UIKeyboardAppearanceAlert;
p = [[UITextField alloc] initWithFrame:CGRectMake(20.0, 100.0, 200.0, 25.0)];
p.text = @"";
p.backgroundColor = [UIColor whiteColor];
p.clearButtonMode = UITextFieldViewModeWhileEditing;
p.keyboardType = UIKeyboardTypeAlphabet;
p.keyboardAppearance = UIKeyboardAppearanceAlert;
[login addSubview:k];
[login addSubview:p];
[login show];
}