iOS7中 textField用autolayout发生问题


开发iOS APP 在iOS8中textField的没问题,约束也正常,换到iOS7的模拟器结果报错
报错信息为 Auto Layout still required after executing -layoutSubviews. UITextField's implementation of -layoutSubviews needs to call super.'
界面一共有两个textField,点击任意一个都会触发这个bug,导致程序崩溃.请问应该怎么解决?

另附堆栈信息
*** First throw call stack:
(
0 CoreFoundation 0x000000010cdc5495 exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010c7bb99e objc_exception_throw + 43
2 CoreFoundation 0x000000010cdc531a +[NSException raise:format:arguments:] + 106
3 Foundation 0x000000010c357f19 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 189
4 UIKit 0x000000010d0dfa3a -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 521
5 QuartzCore 0x000000010c1f7802 -[CALayer layoutSublayers] + 151
6 QuartzCore 0x000000010c1ec369 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 363
7 QuartzCore 0x000000010c1ec1ea _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
8 QuartzCore 0x000000010c15ffb8 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 252
9 QuartzCore 0x000000010c161030 _ZN2CA11Transaction6commitEv + 394
10 UIKit 0x000000010d07e024 _UIApplicationHandleEventQueue + 10914
11 CoreFoundation 0x000000010cd54d21 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION
+ 17
12 CoreFoundation 0x000000010cd545f2 __CFRunLoopDoSources0 + 242
13 CoreFoundation 0x000000010cd7046f __CFRunLoopRun + 767
14 CoreFoundation 0x000000010cd6fd83 CFRunLoopRunSpecific + 467
15 GraphicsServices 0x000000010f42df04 GSEventRunModal + 161
16 UIKit 0x000000010d07fe33 UIApplicationMain + 1010
17 YCPai 0x000000010a863aff main + 111
18 libdyld.dylib 0x000000010e37c5c9 start + 1
19 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Message from debugger: Terminated due to signal 6

uitextfield ios 移动应用开发 autolayout objective-c

夜猫zhi 10 years ago

Auto Layout still required after executing -layoutSubviews. UITextField's implementation of -layoutSubviews needs to call super.
光看错误信息的话 你应该是


 - (void)layoutSubviews {
 //    [super layoutSubviews]; 缺少这一行代码   
}

双马尾娇羞妹控 answered 10 years ago

Your Answer