ios - UITextField 遇到 UIAlertViewStyleSecureTextInput 会崩溃,怎么解?
PHP中文网
PHP中文网 2017-04-17 15:05:22
[iOS讨论组]
- (void)viewDidLoad {

    _textField1 = [[UITextField alloc] initWithFrame:CGRectMake(30, 150, 250, 40)];

    _textField1.delegate = self;
    _textField1.placeholder = @"text1";
    [self.view addSubview:_textField1];

    UIButton *alertBtn = [[UIButton alloc] initWithFrame:CGRectMake(100, 200, 40, 30)];
    alertBtn.backgroundColor = [UIColor redColor];
    [self.view addSubview:alertBtn];
    [alertBtn addTarget:self action:@selector(alertTapped) forControlEvents:UIControlEventTouchUpInside];
    [self addTextField];
}

- (void)alertTapped
{
    UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Title"
                                             message:@"Message"
                                            delegate:nil
                                   cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
    [myAlertView setAlertViewStyle:
     UIAlertViewStyleSecureTextInput];
    [myAlertView setDelegate:self];
    [myAlertView show];
}


只要textfield里面有字,一点button 就会崩溃。

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The layout constraints still need update after sending -updateConstraints to <_UIKeyboardLayoutAlignmentView: 0x137d46830; frame = (0 0; 0 0); userInteractionEnabled = NO; layer = <CALayer: 0x170226d60>>.
_UIKeyboardLayoutAlignmentView or one of its superclasses may have overridden -updateConstraints without calling super. Or, something may have dirtied layout constraints in the middle of updating them.  Both are programming errors.'
*** First throw call stack:
(0x1826682d8 0x193e3c0e4 0x182668218 0x18776c748 0x18776c880 0x182548cdc 0x18776c620 0x18776c880 0x182548cdc 0x18776c620 0x18776c880 0x1871a37b4 0x1834c9308 0x1871a34d0 0x1871bfe04 0x18776cbe4 0x1870ba140 0x187579bd0 0x1873b0fb0 0x18712c240 0x18709c6ec 0x1826202a4 0x18261d230 0x18261d610 0x1825492d4 0x18bd676fc 0x18710efac 0x100062a18 0x1944baa08)
libc++abi.dylib: terminating with uncaught exception of type NSException
PHP中文网
PHP中文网

认证高级PHP讲师

全部回复(1)
ringa_lee

我用了你贴的代码,是没有问题的,但是我注释了“[self addTextField];”这行代码,因为你没把方法贴出来。

或许你可以把完整的代码贴上来(或Demo)。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号