setTranslatesAutoresizingMaskIntoConstraints和setFrame组合使用导致的异常
在用Ojbect-c开发OSX应用的时候需要用到自定义控件并用代码进行布局,很自然地就使用了setTranslatesAutoresizingMaskIntoConstraints和setFrame组合,同时这个组合也很好的满足的需求。但是每当我先当前项目添加一个异常断点的时候,并开启调试程序,总是停在程序刚启动的main函数。经过debug发现是应为setTranslatesAutoresizingMaskIntoConstraints和setFrame组合导致了这个异常。
代码
[_programHeadView setTranslatesAutoresizingMaskIntoConstraints:YES];
[_programHeadView setFrame:headRect];
解决办法
在调用setTranslatesAutoresizingMaskIntoConstraints和setFrame之前先把view从父view用移除,调用之后再添加回去这样就能避免当前view的constraints和默认的constraints产生冲突。
[_programHeadView removeFromSuperview];
[_programHeadView setTranslatesAutoresizingMaskIntoConstraints:YES];
[_programHeadView setFrame:headRect];
[[[self window] contentView] addSubview:_programHeadView];
异常信息
* thread #: tid = 0x6931b, 0x00007fffb1b5745d libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
* frame #: 0x00007fffb1b5745d libobjc.A.dylib`objc_exception_throw
frame #: 0x00007fff9cde1c3d CoreFoundation`+[NSException raise:format:] +
frame #: 0x00007fff9b2a7014 AppKit`LAYOUT_CONSTRAINTS_NOT_SATISFIABLE +
frame #: 0x00007fff9b2a717e AppKit`-[NSView(NSConstraintBasedLayout) engine:willBreakConstraint:dueToMutuallyExclusiveConstraints:] +
frame #: 0x00007fff9e994fea Foundation`-[NSISEngine handleUnsatisfiableRowWithHead:body:usingInfeasibilityHandlingBehavior:mutuallyExclusiveConstraints:] +
frame #: 0x00007fff9e996006 Foundation`-[NSISEngine tryUsingArtificialVariableToAddConstraintWithMarker:rowBody:usingInfeasibilityHandlingBehavior:mutuallyExclusiveConstraints:] +
frame #: 0x00007fff9e729325 Foundation`-[NSISEngine tryToAddConstraintWithMarker:expression:integralizationAdjustment:mutuallyExclusiveConstraints:] +
frame #: 0x00007fff9e99ea01 Foundation`-[NSLayoutConstraint _addLoweredExpression:toEngine:integralizationAdjustment:lastLoweredConstantWasRounded:mutuallyExclusiveConstraints:] +
frame #: 0x00007fff9e7207ac Foundation`-[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] +
frame #: 0x00007fff9a822033 AppKit`-[NSView(NSConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:integralizationAdjustment:mutuallyExclusiveConstraints:] +
frame #: 0x00007fff9a7b68ba AppKit`-[NSView(NSConstraintBasedLayout) _constraints_didChangeAutoresizingConstraintsArrayForContainedView:] +
frame #: 0x00007fff9a83c3ed AppKit`-[NSView updateConstraints] +
frame #: 0x00007fff9a83bf27 AppKit`-[NSView _updateConstraintsForSubtreeIfNeededCollectingViewsWithInvalidBaselines:] +
frame #: 0x00007fff9a83bd31 AppKit`-[NSView _updateConstraintsForSubtreeIfNeededCollectingViewsWithInvalidBaselines:] +
frame #: 0x00007fff9a884c26 AppKit`__82-[NSView _updateConstraintsForSubtreeIfNeededCollectingViewsWithInvalidBaselines:]_block_invoke +
frame #: 0x00007fff9e726adb Foundation`-[NSISEngine withBehaviors:performModifications:] +
frame #: 0x00007fff9a83bc33 AppKit`-[NSView _updateConstraintsForSubtreeIfNeededCollectingViewsWithInvalidBaselines:] +
frame #: 0x00007fff9b059c84 AppKit`__46-[NSView _updateConstraintsForSubtreeIfNeeded]_block_invoke +
frame #: 0x00007fff9e726adb Foundation`-[NSISEngine withBehaviors:performModifications:] +
frame #: 0x00007fff9a7b5760 AppKit`-[NSView(NSConstraintBasedLayout) _withAutomaticEngineOptimizationDisabled:] +
frame #: 0x00007fff9b059a79 AppKit`-[NSView _updateConstraintsForSubtreeIfNeeded] +
frame #: 0x00007fff9b2acbb8 AppKit`-[NSWindow(NSConstraintBasedLayout) _updateConstraintsForEngineHostingViews:] +
frame #: 0x00007fff9a884a7a AppKit`__62-[NSWindow(NSConstraintBasedLayout) updateConstraintsIfNeeded]_block_invoke +
frame #: 0x00007fff9e726adb Foundation`-[NSISEngine withBehaviors:performModifications:] +
frame #: 0x00007fff9a7b5760 AppKit`-[NSView(NSConstraintBasedLayout) _withAutomaticEngineOptimizationDisabled:] +
frame #: 0x00007fff9a88496e AppKit`-[NSWindow(NSConstraintBasedLayout) updateConstraintsIfNeeded] +
frame #: 0x00007fff9a9248fb AppKit`___NSWindowGetDisplayCycleObserver_block_invoke +
frame #: 0x00007fff9a924831 AppKit`__37+[NSDisplayCycle currentDisplayCycle]_block_invoke +
frame #: 0x00007fffa2802dc6 QuartzCore`CA::Transaction::run_commit_handlers(CATransactionPhase) +
frame #: 0x00007fffa290c8f0 QuartzCore`CA::Context::commit_transaction(CA::Transaction*) +
frame #: 0x00007fffa28018a1 QuartzCore`CA::Transaction::commit() +
frame #: 0x00007fff9ac07b99 AppKit`__37+[NSDisplayCycle currentDisplayCycle]_block_invoke. +
frame #: 0x00007fff9ccf8dd7 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ +
frame #: 0x00007fff9ccf8d47 CoreFoundation`__CFRunLoopDoObservers +
frame #: 0x00007fff9ccd9789 CoreFoundation`__CFRunLoopRun +
frame #: 0x00007fff9ccd91c4 CoreFoundation`CFRunLoopRunSpecific +
frame #: 0x00007fff9c23aebc HIToolbox`RunCurrentEventLoopInMode +
frame #: 0x00007fff9c23abf9 HIToolbox`ReceiveNextEventCommon +
frame #: 0x00007fff9c23ab26 HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter +
frame #: 0x00007fff9a7d5e24 AppKit`_DPSNextEvent +
frame #: 0x00007fff9af5185e AppKit`-[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] +
frame #: 0x00007fff9a7ca7ab AppKit`-[NSApplication run] +
frame #: 0x00007fff9a7951de AppKit`NSApplicationMain +
setTranslatesAutoresizingMaskIntoConstraints和setFrame组合使用导致的异常的更多相关文章
- alias导致virtualenv异常的分析和解法
title: alias导致virtualenv异常的分析和解法 toc: true comments: true date: 2016-06-27 23:40:56 tags: [OS X, ZSH ...
- VS2012外接程序VMDebugger未能加载或导致了异常
转http://blog.csdn.net/maryhuan/article/details/42676915 故障现象:打开Visual Studio 2010后弹出错误框,外接程序VMDebugg ...
- Fragment已经被added了导致的异常。
java.lang.IllegalStateException: Fragment already added: ******Effect 出现的原因是commit方法提交是异步的,所以容易出现,判 ...
- 【原创】访问Linux进程文件表导致系统异常复位的排查记录
前提知识: Linux内核.Linux 进程和文件数据结构.vmcore解析.汇编语言 问题背景: 这个问题出自项目的一个安全模块,主要功能是确定某进程是否有权限访问其正在访问的文件. 实现功能时,需 ...
- MySQL Replication--修改主键为NULL导致的异常
测试环境:MySQL 5.5.14/MySQL 5.6.36 测试脚本: create table tb001(id int primary key,c1 int); alter table tb00 ...
- 第四章 TCP粘包/拆包问题的解决之道---4.2--- 未考虑TCP粘包导致功能异常案例
4.2 未考虑TCP粘包导致功能异常案例 如果代码没有考虑粘包/拆包问题,往往会出现解码错位或者错误,导致程序不能正常工作. 4.2.1 TimeServer 的改造 Class : TimeServ ...
- Tomcat8.5 升级tomcat版本导致出现异常,Base64不存在
Tomcat8.5 升级tomcat版本导致出现异常,Base64不存在 原因分析: 由于tomcat由7升级到8.5导致Base64的引用路径错误,默认引用为8.5中的jar, 解决方案: 修改引用 ...
- 代码中会话同步(同步redis)导致的异常问题
背景: 第一天拷贝了一份tomcat(配置了redis会话同步),部署了erp-rocketmq应用(用作给顾客发送消息). 第二天早晨,整个erp系统出现异常情况: 1> ...
- ArcGIS for Android 10.1.1API 中文标注导致程序异常崩溃问题
1.前言 问题:在部分Android机型中使用ArcGIS for Android 10.1.1 API 中文标注导致程序异常崩溃. 说明:手里有两台机器一台是Nexus4,原生系统,版本4.4.4, ...
随机推荐
- Nubia Z5S官方4.4 UI2.0音频Audio部分简单分析(也适用于其它8974/8064机型)以及降低破音出现几率的方法
转载请注明出处和网址链接: http://blog.csdn.net/syhost/article/details/31419749 此篇本是在Z5S的官方4.4内測版出来时写的, 主要是看到其在au ...
- Nodejs 天涯帖子《鹿鼎记中计》 柳成萌著 下载爬虫
功能:从天涯帖子中下载楼主发言到一个文本文件中 实验对象:http://bbs.tianya.cn/post-no05-308123-1.shtml <鹿鼎记中计> 柳成萌著 爬取效果: ...
- 10个CSS简写技巧让你永远受用
转自:http://blog.bingo929.com/10-css-shorthand-tips.html 前言: CSS简写就是指将多行的CSS属性声明化成一行,又称为CSS代码优化.CSS简写的 ...
- HAWQ技术解析(八) —— 大表分区
一.HAWQ中的分区表 与大多数关系数据库一样,HAWQ也支持分区表.这里所说的分区表是指HAWQ的内部分区表,外部分区表在后面"外部数据"篇讨论. 在数据仓库应用中 ...
- Citrix服务器虚拟化之二十九 XenApp 6.5发布服务器上的应用程序
Citrix服务器虚拟化之二十九 XenApp 6.5发布服务器上的应用程序 XenApp可发布以下类型的资源向用户提供信息访问,这些资源可在服务器或桌面上虚拟化: 1) 服务器桌面:发布场中服务 ...
- vue - 子路由-路由嵌套
描述:子路由,也叫路由嵌套,采用在children后跟路由数组来实现,数组里和其他配置路由基本相同,需要配置path和component,然后在相应部分添加<router-view/>来展 ...
- JSTL核心标签
JSTL 核心标签库标签共有13个,功能上分为4类: 1.表达式控制标签:out.set.remove.catch 2.流程控制标签:if.choose.when.otherwise 3.循环标签:f ...
- 用sql语句查出和sql相关的性能计数器
一台服务器上,用性能监视器死活显示不出来一部分计数器,没办法,用sql语句查了 --所有和sql相关的计数器 select * from sys.dm_os_performance_counters ...
- MVC4 WebApi开发中如果想支持Session请做好如下几个方面的问题
1.在WebApiConfig中建立建立HttpControllerHandler和HttpControllerRouteHandler 并覆写它 public class SessionRouteH ...
- HDU 5336 XYZ and Drops
Problem Description XYZ is playing an interesting game called "drops". It is played on a r ...