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

iOS 10之前显示数组越界问题 #8

Open
WYTGizmo opened this issue Jun 23, 2017 · 0 comments
Open

iOS 10之前显示数组越界问题 #8

WYTGizmo opened this issue Jun 23, 2017 · 0 comments

Comments

@WYTGizmo
Copy link

在iOS 9.3 iPhone5 真机测试的时候,crash在[[barBackgroundView subviews] objectAtIndex:1],iOS 10 之前导航栏的subView和iOS10之后的有所不同,所以数组中只有一个imageView,显示数组越界;
本来想判断[barBackgroundView subviews]的个数防止越界,绕开了这个赋值操作,结果在第二次跳转的时候crash在了backgroundImageView.image,显示'unrecognized selector sent to instance ',最后只判断了是否存在backgroundImageView就设置透明度,目前iOS 10之前之后的版本都试了,真机也跑通了,就是想想下Cloudox,请问这个判断.image是否为空是否是刚需....可能目前只是没遇到这个bug,而已.

`- (void)setNeedsNavigationBackground:(CGFloat)alpha {
// 导航栏背景透明度设置
UIView *barBackgroundView = [[self.navigationBar subviews] objectAtIndex:0];// _UIBarBackground
UIImageView *backgroundImageView = (UIImageView *)[[barBackgroundView subviews] objectAtIndex:0];// UIImageView
if (self.navigationBar.isTranslucent) {
if (backgroundImageView) {// != nil && backgroundImageView.image != nil
barBackgroundView.alpha = alpha;
} else {

        UIView *backgroundEffectView = [[barBackgroundView subviews] objectAtIndex:1];// UIVisualEffectView
        if (backgroundEffectView != nil) {
            backgroundEffectView.alpha = alpha;
        }
    }
} else {
    barBackgroundView.alpha = alpha;
}

// 对导航栏下面那条线做处理
self.navigationBar.clipsToBounds = alpha == 0.0;

}`

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

1 participant