.xib ファイルで UIViewController を設計しました。オートレイアウトを使用しています。
値が変更されたときに UILabel のテキストを変更する UISlider があります。送信されたイベント「値が変更されました」をヘッダーファイルにリンクし、コントローラーの.mファイルに関数を実装しました。このメソッドは、スライダーの値に応じて、ラベルのテキストのみを変更します。
ビューが表示されるとき、スライダーは表示されません (画面の外側に設定されます)。アニメーションを使用してビューに表示します。問題は、スライダーの値を変更すると、自動的に呼び出されることです
-(void)viewDidLayoutSubviews
{
}
残念ながら、コントローラーのビューのすべてのサブビューが元の位置にリセットされました。
実際のレイアウトを「破壊」するためにスライダーを表示する方法。
編集
インターフェイスビルダーでのスライダーの接続:
および関連する関数のコード:
- (IBAction)sliderDureeValueChanged:(id)sender {
dureeMois = (int) sliderDuree.value;
if (sliderDuree.maximumValue == sliderDuree.value)
{
[lblDuree setText:@"Max"];
}
else if (sliderDuree.minimumValue == sliderDuree.value)
{
[lblDuree setText:@"Min"];
}
else
{
[lblDuree setText:[NSString stringWithFormat:@"%d month",dureeMois]
}
}
EDIT2
これは、スライダーを使用して呼び出されたときに取得[NSThread callStackSymbols]
されるスタックです。viewDidLayoutSubviews
2013-07-16 16:39:47.420 MyApp[2363:907] Stack trace : (
0 MyApp 0x0003cd5f -[GraphiqueFVViewController viewDidLayoutSubviews] + 50
1 UIKit 0x34f938c9 <redacted> + 456
2 QuartzCore 0x34d3dd8b <redacted> + 214
3 QuartzCore 0x34d3d929 <redacted> + 460
4 QuartzCore 0x34d3e85d <redacted> + 16
5 QuartzCore 0x34d3e243 <redacted> + 238
6 QuartzCore 0x34d3e051 <redacted> + 316
7 QuartzCore 0x34d3deb1 <redacted> + 60
8 CoreFoundation 0x3315d6cd <redacted> + 20
9 CoreFoundation 0x3315b9c1 <redacted> + 276
10 CoreFoundation 0x3315bd17 <redacted> + 742
11 CoreFoundation 0x330ceebd CFRunLoopRunSpecific + 356
12 CoreFoundation 0x330ced49 CFRunLoopRunInMode + 104
13 GraphicsServices 0x36c922eb GSEventRunModal + 74
14 UIKit 0x34fe4301 UIApplicationMain + 1120
15 MyApp 0x00021add main + 116
16 libdyld.dylib 0x3b264b20 <redacted> + 0
そして、デバッグ領域ですべてバックトレースします:
* thread #1: tid = 0x2503, 0x00101d46 MyApp`-[GraphiqueFVViewController viewDidLayoutSubviews](self=0x1ed972f0, _cmd=0x3541247c) + 42 at GraphiqueFVViewController.m:386, stop reason = breakpoint 2.1
frame #0: 0x00101d46 MyApp`-[GraphiqueFVViewController viewDidLayoutSubviews](self=0x1ed972f0, _cmd=0x3541247c) + 42 at GraphiqueFVViewController.m:386
frame #1: 0x34f938c8 UIKit`-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 456
frame #2: 0x34d3dd8a QuartzCore`-[CALayer layoutSublayers] + 214
frame #3: 0x34d3d928 QuartzCore`CA::Layer::layout_if_needed(CA::Transaction*) + 460
frame #4: 0x34d3e85c QuartzCore`CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 16
frame #5: 0x34d3e242 QuartzCore`CA::Context::commit_transaction(CA::Transaction*) + 238
frame #6: 0x34d3e050 QuartzCore`CA::Transaction::commit() + 316
frame #7: 0x34d3deb0 QuartzCore`CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 60
frame #8: 0x3315d6cc CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 20
frame #9: 0x3315b9c0 CoreFoundation`__CFRunLoopDoObservers + 276
frame #10: 0x3315bd16 CoreFoundation`__CFRunLoopRun + 742
frame #11: 0x330ceebc CoreFoundation`CFRunLoopRunSpecific + 356
frame #12: 0x330ced48 CoreFoundation`CFRunLoopRunInMode + 104
frame #13: 0x36c922ea GraphicsServices`GSEventRunModal + 74
frame #14: 0x34fe4300 UIKit`UIApplicationMain + 1120
frame #15: 0x000e6a84 MyApp`main(argc=1, argv=0x2fd1bd18) + 116 at main.m:16
frame #16: 0x3b264b20 libdyld.dylib`start + 4
thread #3: tid = 0x2903, 0x3b31b648 libsystem_kernel.dylib`kevent64 + 24
frame #0: 0x3b31b648 libsystem_kernel.dylib`kevent64 + 24
frame #1: 0x3b2544f0 libdispatch.dylib`_dispatch_mgr_invoke + 796
frame #2: 0x3b246df8 libdispatch.dylib`_dispatch_mgr_thread$VARIANT$up + 36
thread #5: tid = 0x2b03, 0x3b31aeb4 libsystem_kernel.dylib`mach_msg_trap + 20
frame #0: 0x3b31aeb4 libsystem_kernel.dylib`mach_msg_trap + 20
frame #1: 0x3b31b04c libsystem_kernel.dylib`mach_msg + 40
frame #2: 0x3315d044 CoreFoundation`__CFRunLoopServiceMachPort + 128
frame #3: 0x3315bda2 CoreFoundation`__CFRunLoopRun + 882
frame #4: 0x330ceebc CoreFoundation`CFRunLoopRunSpecific + 356
frame #5: 0x330ced48 CoreFoundation`CFRunLoopRunInMode + 104
frame #6: 0x390cd504 WebCore`RunWebThread(void*) + 444
frame #7: 0x3b284310 libsystem_c.dylib`_pthread_start + 308
thread #7: tid = 0x241f, 0x3b31aeb4 libsystem_kernel.dylib`mach_msg_trap + 20
frame #0: 0x3b31aeb4 libsystem_kernel.dylib`mach_msg_trap + 20
frame #1: 0x3b31b04c libsystem_kernel.dylib`mach_msg + 40
frame #2: 0x3315d044 CoreFoundation`__CFRunLoopServiceMachPort + 128
frame #3: 0x3315bda2 CoreFoundation`__CFRunLoopRun + 882
frame #4: 0x330ceebc CoreFoundation`CFRunLoopRunSpecific + 356
frame #5: 0x330ced48 CoreFoundation`CFRunLoopRunInMode + 104
frame #6: 0x33a1b3d4 Foundation`+[NSURLConnection(Loader) _resourceLoadLoop:] + 308
frame #7: 0x33a9ee84 Foundation`__NSThread__main__ + 972
frame #8: 0x3b284310 libsystem_c.dylib`_pthread_start + 308
thread #8: tid = 0x2d03, 0x3b32b594 libsystem_kernel.dylib`select$DARWIN_EXTSN + 20
frame #0: 0x3b32b594 libsystem_kernel.dylib`select$DARWIN_EXTSN + 20
frame #1: 0x331611f6 CoreFoundation`__CFSocketManager + 678
frame #2: 0x3b284310 libsystem_c.dylib`_pthread_start + 308
thread #11: tid = 0x3003, 0x3b32b08c libsystem_kernel.dylib`__psynch_cvwait + 24
frame #0: 0x3b32b08c libsystem_kernel.dylib`__psynch_cvwait + 24
frame #1: 0x3b27cd2e libsystem_c.dylib`_pthread_cond_wait + 646
frame #2: 0x3b27caa4 libsystem_c.dylib`pthread_cond_timedwait + 44
frame #3: 0x37088c74 JavaScriptCore`WTF::ThreadCondition::timedWait(WTF::Mutex&, double) + 108
frame #4: 0x3719a556 JavaScriptCore`JSC::BlockAllocator::blockFreeingThreadMain() + 82
frame #5: 0x371acfaa JavaScriptCore`WTF::wtfThreadEntryPoint(void*) + 14
frame #6: 0x3b284310 libsystem_c.dylib`_pthread_start + 308
thread #12: tid = 0x3103, 0x3b31aeb4 libsystem_kernel.dylib`mach_msg_trap + 20
frame #0: 0x3b31aeb4 libsystem_kernel.dylib`mach_msg_trap + 20
frame #1: 0x3b31b04c libsystem_kernel.dylib`mach_msg + 40
frame #2: 0x3315d044 CoreFoundation`__CFRunLoopServiceMachPort + 128
frame #3: 0x3315bda2 CoreFoundation`__CFRunLoopRun + 882
frame #4: 0x330ceebc CoreFoundation`CFRunLoopRunSpecific + 356
frame #5: 0x330ced48 CoreFoundation`CFRunLoopRunInMode + 104
frame #6: 0x39167d06 WebCore`WebCore::runLoaderThread(void*) + 142
frame #7: 0x371acfaa JavaScriptCore`WTF::wtfThreadEntryPoint(void*) + 14
frame #8: 0x3b284310 libsystem_c.dylib`_pthread_start + 308
thread #15: tid = 0x3403, 0x3b32b08c libsystem_kernel.dylib`__psynch_cvwait + 24
frame #0: 0x3b32b08c libsystem_kernel.dylib`__psynch_cvwait + 24
frame #1: 0x3b27cd2e libsystem_c.dylib`_pthread_cond_wait + 646
frame #2: 0x3b286f18 libsystem_c.dylib`pthread_cond_wait + 40
frame #3: 0x37088c46 JavaScriptCore`WTF::ThreadCondition::timedWait(WTF::Mutex&, double) + 62
frame #4: 0x392e1e8c WebCore`WTF::PassOwnPtr<WebCore::StorageTask> WTF::MessageQueue<WebCore::StorageTask>::waitForMessageFilteredWithTimeout<bool (WebCore::StorageTask*)>(WTF::MessageQueueWaitResult&, bool (&)(WebCore::StorageTask*), double) + 56
frame #5: 0x392e1e40 WebCore`WebCore::StorageThread::threadEntryPoint() + 124
frame #6: 0x371acfaa JavaScriptCore`WTF::wtfThreadEntryPoint(void*) + 14
frame #7: 0x3b284310 libsystem_c.dylib`_pthread_start + 308
thread #17: tid = 0x3903, 0x3b32bd98 libsystem_kernel.dylib`__workq_kernreturn + 8
frame #0: 0x3b32bd98 libsystem_kernel.dylib`__workq_kernreturn + 8
frame #1: 0x3b279cfa libsystem_c.dylib`_pthread_workq_return + 18
frame #2: 0x3b279a16 libsystem_c.dylib`_pthread_wqthread + 366
thread #18: tid = 0x3b03, 0x3b32bd98 libsystem_kernel.dylib`__workq_kernreturn + 8
frame #0: 0x3b32bd98 libsystem_kernel.dylib`__workq_kernreturn + 8
frame #1: 0x3b279cfa libsystem_c.dylib`_pthread_workq_return + 18
frame #2: 0x3b279a16 libsystem_c.dylib`_pthread_wqthread + 366
thread #19: tid = 0x3707, 0x3b32bd98 libsystem_kernel.dylib`__workq_kernreturn + 8
frame #0: 0x3b32bd98 libsystem_kernel.dylib`__workq_kernreturn + 8
frame #1: 0x3b279cfa libsystem_c.dylib`_pthread_workq_return + 18
frame #2: 0x3b279a16 libsystem_c.dylib`_pthread_wqthread + 366