【问题标题】:iOS4.0: UIAlertView with UITextField messed upiOS4.0:带有 UITextField 的 UIAlertView 搞砸了
【发布时间】:2019-08-01 15:09:05
【问题描述】:

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

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 时发生。

【问题讨论】:

    标签: uitextfield ios4 uialertview


    【解决方案1】:

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

    【讨论】:

    • 我发现 another way 相当冗长,用于将子视图插入 UIAlertView。缺点是它有一个与覆盖键盘相关的讨厌的错误。
    猜你喜欢
    • 2021-12-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-15
    • 2012-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多