开发者

iOS4.0: UIAlertView with UITextField messed up

开发者 https://www.devze.com 2023-01-06 12:20 出处:网络
this is what i get when using this code: UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@\"Rank on ScoreBoard: %d\",positionOnBoard] message:@\"\" delegate:self

iOS4.0: UIAlertView with UITextField messed up

this is what i get when using this code:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"Rank on ScoreBoard: %d",positionOnBoard] message:@"" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:@"Submit", ni开发者_如何学运维l];
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];

as you see, it's messed up. it only happened when ugrading my project to iOS 4.0.


Eventually I solved it by increasing the height of the UIAlertView by adding a "\n " (YES, it's a space after the \n) to the InitWIthTitle parameter, then i had enough space to place the UITextField correctly.

0

精彩评论

暂无评论...
验证码 换一张
取 消