【问题标题】:Any non-private API alternative for this?有任何非私有 API 替代品吗?
【发布时间】:2010-09-24 04:07:27
【问题描述】:

我的应用最近因使用私有 API 而被拒绝(UIAlertViewaddTextField: 方法,非常有用,我可以补充一下)。

UIAlertView 的无证 addTextFieldWithValue:label: 是否有任何非私人替代方案?

提前非常感谢!

【问题讨论】:

    标签: iphone objective-c uialertview iphone-privateapi


    【解决方案1】:

    将文本字段创建为 UIAlertView 的子视图

    // Ask for Username and password.
    alertView = [[UIAlertView alloc] initWithTitle:_title message:@"\n \n \n" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
    // Adds a username Field
    utextfield = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)]; 
    utextfield.placeholder = @"Username";
    [utextfield setBackgroundColor:[UIColor whiteColor]];
    utextfield.enablesReturnKeyAutomatically = YES;
    [utextfield setReturnKeyType:UIReturnKeyDone];
    [utextfield setDelegate:self];
    [alertView addSubview:utextfield];
    
    // Show alert on screen.
    [alertView show];
    [alertView release];
    

    【讨论】:

    • 好把戏。 (小提示:错过了 utextfield 上的发布。)
    • 非常感谢!希望现在我不必等待两周才能有人拒绝我的应用。
    【解决方案2】:

    查看 GitHub 上的此开源代码,以将 UITextFields 添加到 UIAlertView。

    http://github.com/enormego/EGOTextFieldAlertView

    【讨论】:

      猜你喜欢
      • 2010-12-22
      • 2012-03-04
      • 2020-03-16
      • 2011-07-17
      • 2017-03-05
      • 2021-03-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多