UITextField in UIAlertView alternative?

前端 未结 4 428
逝去的感伤
逝去的感伤 2021-01-15 21:56

I want a quick input from a user. I know I can put a UITextField in UIAlertView but it\'s sort of a \"hack\". Is there an official/alternative way to do this?

It\'s

相关标签:
4条回答
  • 2021-01-15 22:18

    If you're willing to require iOS 5 then it's no longer a hack. UIAlertView now has a alertViewStyle property which, when set to UIAlertViewStylePlainTextInput, adds a single text field to the alert that you can retrieve with -[UIAlertView textFieldAtIndex:].

    If you still require 4.3 or earlier, then no, there's no official way to do this and it really is a big "hack" that's on par with calling SPI.

    0 讨论(0)
  • 2021-01-15 22:22

    I had the exact same problem and have fixed it and seems to work in both iOS 4.3 and 5.0. It seems there are some other classes further down throwing off the computing of the offsetY value. Instead of updating offsetY for all non-UIControl classes I changed it to only update it for UILabel classes.

    Here is my fix in EGOTextFieldAlertView.m in layoutSubviews

    change this line: if(![view isKindOfClass:[UIControl class]]) {
    to: if([view isKindOfClass:[UILabel class]]) {

    0 讨论(0)
  • 2021-01-15 22:38

    If your looking for an alternative way then you can create custom UIView thats looks like alert view and add as subview and make animation like alert view.

    0 讨论(0)
  • 2021-01-15 22:42

    Check out EGOTextFieldAlertView.

    0 讨论(0)
提交回复
热议问题