UITextField在iOS 7.1上没有响应

时间:2014-01-10 05:38:27

标签: ios xcode uiview uitextfield uiwindow

我有一个abstract class UIView子类。

它会在新UIWindow上创建一个视图,并向用户显示我的Custom alert

我有一个继承自此抽象类的AuthorizationView类,它包含一些UITextFields

问题:如果我现在构建它并发送给测试人员,这些UITextFields不会对iOS 7.1 beta做出响应。 旧版本的项目在iOS 7.1 beta上运行良好(来自AppStore)。 任何版本在iOS 6.0 - iOS 7.0上都能正常运行。我无法在iOS 7.1 beta上自行测试。

有什么建议吗?

UITextField创作:

fieldUser = [[UITextField alloc] initWithFrame:AUTH_FIELD_USER_FRAME];
[fieldUser setBackgroundColor:kColorClear];
[fieldUser setBorderStyle:UITextBorderStyleNone];
[fieldUser setTextAlignment:NSTextAlignmentLeft];
[fieldUser setKeyboardType:UIKeyboardTypeEmailAddress];
[fieldUser setKeyboardAppearance:[[DatabaseManager sharedInstance] keyboard]];
[fieldUser setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
[fieldUser setAutocorrectionType:UITextAutocorrectionTypeNo];
[fieldUser setAutocapitalizationType:UITextAutocapitalizationTypeNone];
[fieldUser setReturnKeyType:UIReturnKeyNext];
[fieldUser setDelegate:self];
[fieldUser setPlaceholder:NSLocalizedString(@"Window_Login_Placeholder_User", @"")];
[fieldUser setFont:kFontNormal(16.0f)];
[self addSubview:fieldUser];

抽象类:

#import "AlertWindow.h"

@interface AlertWindow ()
{
    CGFloat alpha;
}

@property (nonatomic, strong) UIWindow *window;

@end

@implementation AlertWindow

- (id) init
{
    self = [super init];
    if (self)
    {
        alpha = 0.8f;
    }
    return self;
}

- (id) initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        alpha = 0.8f;
    }
    return self;
}

- (void) showAnimated:(BOOL)animated_
{
    UIView *view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [view setBackgroundColor:[UIColor blackColor]];
    [view setAlpha:alpha];
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.windowLevel = UIWindowLevelAlert;
    self.window.backgroundColor = kColorClear;
    [self.window addSubview:view];
    [self.window addSubview:self];
    self.window.alpha = 0.0f;
    [self.window makeKeyAndVisible];
    if (animated_)
    {
        __block UIWindow *animationWindow = self.window;
        [UIView animateWithDuration:UINavigationControllerHideShowBarDuration animations:^{
            animationWindow.alpha = 1.0f;
        }];
    }
    else
    {
        self.window.alpha = 1.0f;
    }
}

- (void) hideAnimated:(BOOL)animated_
{
    if (animated_)
    {
        __block UIWindow *animationWindow = self.window;
        [UIView animateWithDuration:UINavigationControllerHideShowBarDuration animations:^{
            animationWindow.alpha = 0.0f;
        } completion:^(BOOL finished) {
            self.window.hidden = YES;
            self.window = nil;
        }];
    }
    else
    {
        self.window.hidden = YES;
        self.window = nil;
    }
}

- (void) hideAnimated
{
    [self hideAnimated:YES];
}

- (void) setBackgroundAplha:(CGFloat)alpha_
{
    alpha = alpha_;
}

@end

1 个答案:

答案 0 :(得分:0)

所有Event Delegate方法都将触及应用程序的主窗口。现在你已经创建了另一个窗口,可能是你的委托正在调用,但是因为这个新窗口而隐藏了。只需使窗口颜色清晰并验证,或者尝试打印文本字段文本输入一些文本,会让你知道是否被触发?