我有这种情况。我有VC,其中我想显示滚动视图,它将为该VC提供一组子屏幕。用户应该能够滚动子屏幕(以分页方式)。子屏幕的数量和基本布局始终相同,因此我想在故事板中创建内容。所以我这样做了:
我的想法是,当布局结束时,容器视图将强制新VC将其自身调整到其边界,但子屏幕视图的约束将保持UIScrollerView的内容视图,就像它在故事板中一样。而且我是对的,当滚动被禁用时一切正常并且看起来我希望它看起来并且滚动得很好,但是当我打开分页并滚动时,有些事情会发生并且应用程序崩溃。
我做了很多日志记录,scrollview的数字,内容,矩形看起来很好,因为它们应该看起来
任何人都有任何想法,我做错了什么,可能出错? 提前谢谢......
堆栈跟踪: 线程0崩溃:
0 libsystem_kernel.dylib 0x387211f0 __pthread_kill + 8
1 libsystem_pthread.dylib 0x3878b792 pthread_kill + 54
2 libsystem_c.dylib 0x386d1fd8 abort + 72
3 MyApp 0x001a8f36 uncaught_exception_handler + 22
4 CoreFoundation 0x2d5be2d4 __handleUncaughtException + 576
5 libobjc.A.dylib 0x3815ef50 _objc_terminate() + 172
6 libc++abi.dylib 0x37a171c4 std::__terminate(void (*)()) + 76
7 libc++abi.dylib 0x37a16d28 __cxa_rethrow + 96
8 libobjc.A.dylib 0x3815ee12 objc_exception_rethrow + 38
9 CoreFoundation 0x2d4f1f80 CFRunLoopRunSpecific + 636
10 CoreFoundation 0x2d4f1cee CFRunLoopRunInMode + 102
11 GraphicsServices 0x3241765e GSEventRunModal + 134
12 UIKit 0x2fe3d168 UIApplicationMain + 1132
13 MyApp 0x0017a530 main (main.m:16)
14 libdyld.dylib 0x3866bab4 start + 0
Last Exception Backtrace:
0 CoreFoundation 0x2d5bdfce __exceptionPreprocess + 126
1 libobjc.A.dylib 0x3815ecca objc_exception_throw + 34
2 CoreFoundation 0x2d5bdf10 +[NSException raise:format:] + 100
3 QuartzCore 0x2fa4e644 CA::Layer::set_bounds(CA::Rect const&, bool) + 308
4 QuartzCore 0x2fa4e44a -[CALayer setBounds:] + 106
5 UIKit 0x2fe253d4 -[UIView(Geometry) setBounds:] + 324
6 UIKit 0x2fe33414 -[UIScrollView setBounds:] + 1060
7 UIKit 0x2fdf9182 -[UIScrollView setContentOffset:] + 554
8 UIKit 0x2ff750da -[UIScrollView _smoothScrollWithUpdateTime:] + 2970
9 QuartzCore 0x2faa5dee CA::Display::DisplayLinkItem::dispatch() + 94
10 QuartzCore 0x2faa5b98 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 340
11 IOMobileFramebuffer 0x3283f758 IOMobileFramebufferVsyncNotifyFunc + 100
12 IOKit 0x2e2a844c IODispatchCalloutFromCFMessage + 244
13 CoreFoundation 0x2d57def4 __CFMachPortPerform + 132
14 CoreFoundation 0x2d588ab2 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 30
15 CoreFoundation 0x2d588a4e __CFRunLoopDoSource1 + 342
16 CoreFoundation 0x2d587222 __CFRunLoopRun + 1394
17 CoreFoundation 0x2d4f1f0a CFRunLoopRunSpecific + 518
18 CoreFoundation 0x2d4f1cee CFRunLoopRunInMode + 102
19 GraphicsServices 0x3241765e GSEventRunModal + 134
20 UIKit 0x2fe3d168 UIApplicationMain + 1132
21 MyApp 0x0017a530 main (main.m:16)
22 libdyld.dylib 0x3866bab2 tlv_initializer + 2