Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

由竖屏到横屏,控件布局正确,但是事件不响应了 #128

Open
xiu619544553 opened this issue Jul 7, 2020 · 1 comment
Open

Comments

@xiu619544553
Copy link

MyLinearLayout 贴满 vc.view。

linearLayout上添加一个button,如下:

  • (UIButton *)submitBtn {
    if (!_submitBtn) {
    _submitBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _submitBtn.adjustsImageWhenHighlighted = NO;
    _submitBtn.myHeight = 50.f;
    _submitBtn.layer.cornerRadius = 10.f;
    _submitBtn.myWidth = 160.f;
    _submitBtn.myAlignment = MyGravity_Horz_Center;
    _submitBtn.myTop = 30.f;
    }
    return _submitBtn;
    }

问题1:横屏后,submitBtn 事件不响应;竖屏后,submitBtn可以响应事件。
问题2:在控制器 -viewDidLayoutSubviews 方法中打印 submitBtn,每次 frame都发生变化,实际上页面未发生变化。这个问题普遍存在。

@youngsoft
Copy link
Owner

一般不响应事件的原因就是您在横屏时submitBtn的父视图,或者父视图的父视图的尺寸发生了变化。更确切的说就是横屏时那些父视图的宽高出现问题了导致事件无法传递到submitBtn上,建议您在横屏时调试一下视图树是不是这个原因导致的。另外建议您贴出submitBtn的父视图,以及父视图的父视图的布局约束代码,以便更加精确的定位问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants