iOS4.0:带有UITextField的UIAlertView搞砸了

时间:2010-07-07 13:36:09

标签: uitextfield ios4 uialertview

http://www.freeimagehosting.net/uploads/494c515b14.jpg http://www.freeimagehosting.net/uploads/494c515b14.jpg

这是我在使用此代码时得到的结果:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Rank on ScoreBoard: %d",positionOnBoard] message:@"" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:@"Submit", nil];
nameField = [[UITextField alloc] initWithFrame:CGRectMake(12, 25, 260, 21)];

[nameField setBackgroundColor:[UIColor whiteColor]];
[nameField setPlaceholder:@"Your Name Here!"];

[alert addSubview:nameField];

[alert show];

[nameField becomeFirstResponder];

[alert release];

如你所见,它搞砸了。 它只发生在将我的项目升级到iOS 4.0时。

1 个答案:

答案 0 :(得分:0)

最终我通过在InitWIthTitle参数中添加“\ n”(YES,它是\ n后面的空格)来增加UIAlertView的高度来解决它,然后我有足够的空间来正确放置UITextField。