【发布时间】:2018-03-14 06:40:12
【问题描述】:
我最近更新了我的 Xcode,更新 Xcode 后我面临崩溃。 这里发生了崩溃
UIBlurEffect *blur = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
UIVisualEffectView *vsview = [[UIVisualEffectView alloc]initWithEffect:blur];
_bgView = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
_bgView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.8];
_bgView.alpha = 0;
_bgView.userInteractionEnabled = YES;
UITapGestureRecognizer *buttonTap2 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(handleTap:)];
buttonTap2.cancelsTouchesInView = NO;
vsview.frame = _bgView.bounds;
_bgView = vsview;
[_bgView addGestureRecognizer:buttonTap2];
_normalImageView = [[UIImageView alloc]initWithFrame:self.bounds];
_normalImageView.userInteractionEnabled = YES;
_normalImageView.contentMode = UIViewContentModeScaleAspectFit;
_normalImageView.layer.shadowColor = [UIColor blackColor].CGColor;
_normalImageView.layer.shadowRadius = 5.f;
_normalImageView.layer.shadowOffset = CGSizeMake(-10, -10);
_pressedImageView = [[UIImageView alloc]initWithFrame:self.bounds];
_pressedImageView.contentMode = UIViewContentModeScaleAspectFit;
_pressedImageView.userInteractionEnabled = YES;
_normalImageView.image = _normalImage;
_pressedImageView.image = _pressedImage;
[_bgView addSubview:_menuTable];
其中_bgView 是UIView 而_menuTable 是UITableView;
说明以下错误消息的日志。
-[UIVisualEffectView 中的断言失败 _addSubview:positioned:relativeTo:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3698.34.4/UIVisualEffectView.m:1558
由于未捕获的异常 NSInternalInconsistencyException 而终止应用程序',原因:'; 层 = ;内容偏移:{0, 0};内容大小: {281.25, 72}; adjustedContentInset: {0, 0, 0, 0}> 已添加为 子视图;层=>。不要将子视图直接添加到视觉效果视图中 本身,而是将它们添加到 -contentView。
在更新他的 Xcode 之前它工作正常。
【问题讨论】:
-
你到底在问什么?因为您需要解决的所有问题都在您提供的崩溃描述中。
-
我尝试添加 [_bgView.contentView addSubview:_menuTable];但如果我试图让 _bgView 有一个背景透明视图并且它没有显示。
-
好吧,实际上,您在
_bgView上设置alpha = 0与您编写代码的方式无关,因为您稍后将vsView分配给该变量,因此之前的所有内容都会被丢弃。有没有办法提供MCVE?
标签: ios objective-c xcode crash uivisualeffectview