enormego / EGOTextFieldAlertView

UIAlertView subclass that adds support for UITextFields, without using any private methods.
http://developers.enormego.com
88 stars 15 forks source link

Does not work on iOS 4 #2

Open olegam opened 14 years ago

olegam commented 14 years ago

When build for iOS 4 the alert view is displayed too high and text input does not work.

tobiasbayer commented 14 years ago

Confirm

olegam commented 14 years ago

As a replacement you can use http://github.com/erica/iphone-3.0-cookbook-/tree/master/C10-Alerts/03-Soliciting%20Text/

jupiter commented 14 years ago

Would be great if someone solves this issue without using a totally different implementation. I'd prefer getting it to work.

josecastillo commented 14 years ago

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.

jupiter commented 14 years ago

Brilliant! That fixes it. Thanks.

josecastillo commented 14 years ago

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.

gonso75 commented 13 years ago

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

jupiter commented 13 years ago

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

hellhound commented 13 years ago

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

CodeSix commented 12 years ago

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]])