EGOTextFieldAlertView
EGOTextFieldAlertView copied to clipboard
Does not work on iOS 4
When build for iOS 4 the alert view is displayed too high and text input does not work.
Confirm
As a replacement you can use http://github.com/erica/iphone-3.0-cookbook-/tree/master/C10-Alerts/03-Soliciting%20Text/
Would be great if someone solves this issue without using a totally different implementation. I'd prefer getting it to work.
The text input issue has to do with the UITextField being a subview of the EGOAlertTextFieldBack. The fix is to add the backView as a subview of the alertView, and add the textView as a sibling positioned atop it. You'll have to do a little bit of finangling with the geometry, but it's not terribly difficult.
Re: the positioning of the alertview itself, just delete the line: self.transform = CGAffineTransformTranslate(self.transform, 0.0f, 150.0f); Under iOS 4, it appears the OS automatically handles repositioning of a UIAlertView when one of its text fields becomes first responder.
Brilliant! That fixes it. Thanks.
Anyone who is using this class and needs an iOS 4 fix, here is my fork of the class. Fixes text input issue and the positioning weirdness.
http://github.com/josecastillo/EGOTextFieldAlertView
Caveat: to fix the latter issue, I added a bigger delay from the [alert show] to the keyboard appearing. See comments in -show if you wanna take a stab at something more clever.
josecastillo's fix was working great for iOS 4, but it stopped working on 4.3 and on iPad 4.2+.
I have no clue why, but the text boxes wont move up with the alert when the keyboard appears....
any ideas? Gonso
Gonso,
I found a fix for josecastillo's EGOTextFieldAlertView.
In EGOTextFieldAlertView.m, it is detecting the wrong Y offset due to a new UIImageView in the UIAlertView subviews. Therefore, replace:
if(![view isKindOfClass:[UIControl class]]) {
with:
if(![view isKindOfClass:[UIControl class]] && ![view isKindOfClass:[UIImageView class]]) {
And all works as before.
Best, Pieter
I managed to hack Tom Swift's UIAlertView re-implementation. I added iOS 3 backward compatibility and multiple UITextField API :) https://github.com/bitzeppelin/TSAlertView
The textfield issue was fixed by changing -layoutSubviews in .m:
if (![view isKindOfClass:[UIControl class]])
to
if (![view isKindOfClass:[UIControl class]] && ![view isKindOfClass:[UIImageView class]] && ![view isKindOfClass:[EGOAlertTextFieldBack class]])