2012-08-15 71 views
0

我有當UISwitcher被改變時執行以下代碼:的iOS的UIDatePicker崩潰與(幾乎)無限循環

if(switcher.on == YES) { 
    self.pickerView.datePickerMode = UIDatePickerModeDate; 
} 
else { 
    self.pickerView.datePickerMode = UIDatePickerModeTime; 
} 

這導致應用在模擬器崩潰與以下堆棧跟蹤:

* thread #1: tid = 0x1f03, 0x027997dc CoreFoundation`CFNumberGetValue + 12, stop reason = EXC_BAD_ACCESS (code=2, address=0xbf7fffec) 
frame #0: 0x027997dc CoreFoundation`CFNumberGetValue + 12 
frame #1: 0x02843d2c CoreFoundation`-[__NSCFNumber longValue] + 76 
frame #2: 0x02843ed1 CoreFoundation`-[__NSCFNumber integerValue] + 33 
frame #3: 0x0a624255 UIKit`-[UIPickerViewAccessibility(SafeCategory) accessibilityContainerElements] + 99 
frame #4: 0x08f61424 UIAccessibility`-[NSObject(AXPrivCategory) accessibilityElementCount] + 34 
frame #5: 0x08f6135b UIAccessibility`-[NSObject(AXPrivCategory) _accessibilityResetContainerElements] + 75 

... 

frame #196418: 0x08f6135b UIAccessibility`-[NSObject(AXPrivCategory) _accessibilityResetContainerElements] + 75 
frame #196419: 0x0a624290 UIKit`-[UIPickerViewAccessibility(SafeCategory) accessibilityContainerElements] + 158 
frame #196420: 0x08f61424 UIAccessibility`-[NSObject(AXPrivCategory) accessibilityElementCount] + 34 
frame #196421: 0x08f6135b UIAccessibility`-[NSObject(AXPrivCategory) _accessibilityResetContainerElements] + 75 
frame #196422: 0x0a624290 UIKit`-[UIPickerViewAccessibility(SafeCategory) accessibilityContainerElements] + 158 
frame #196423: 0x08f61424 UIAccessibility`-[NSObject(AXPrivCategory) accessibilityElementCount] + 34 
frame #196424: 0x08f6135b UIAccessibility`-[NSObject(AXPrivCategory) _accessibilityResetContainerElements] + 75 
frame #196425: 0x0a624465 UIKit`-[UIPickerViewAccessibility(SafeCategory) reloadAllComponents] + 68 
frame #196426: 0x00ca8b18 UIKit`-[UIDatePickerView _updateBitsForDate:forced:andReload:animateIfNeeded:] + 611 
frame #196427: 0x00ca9116 UIKit`-[UIDatePickerView _setDate:animated:forced:] + 372 
frame #196428: 0x00caa13b UIKit`-[UIDatePickerView setDatePickerMode:] + 535 
frame #196429: 0x00ca7669 UIKit`-[UIDatePicker setDatePickerMode:] + 51 
frame #196430: 0x0005ba9b MyApp`-[RRDatePickerViewController switchChanged:] + 283 at RRDatePickerViewController.m:249 
frame #196431: 0x02876e99 CoreFoundation`-[NSObject performSelector:withObject:withObject:] + 73 
frame #196432: 0x00aa914e UIKit`-[UIApplication sendAction:to:from:forEvent:] + 96 
frame #196433: 0x00aa90e6 UIKit`-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61 
frame #196434: 0x00b4fade UIKit`-[UIControl sendAction:to:forEvent:] + 66 
frame #196435: 0x00b4ffa7 UIKit`-[UIControl(Internal) _sendActionsForEvents:withEvent:] + 503 
frame #196436: 0x00ca3c16 UIKit`-[_UISwitchInternalView _sendActions] + 121 
frame #196437: 0x013cc85d Foundation`__NSFireDelayedPerform + 389 
frame #196438: 0x02849936 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22 
frame #196439: 0x028493d7 CoreFoundation`__CFRunLoopDoTimer + 551 
frame #196440: 0x027ac790 CoreFoundation`__CFRunLoopRun + 1888 
frame #196441: 0x027abd84 CoreFoundation`CFRunLoopRunSpecific + 212 
frame #196442: 0x027abc9b CoreFoundation`CFRunLoopRunInMode + 123 
frame #196443: 0x02cf97d8 GraphicsServices`GSEventRunModal + 190 
frame #196444: 0x02cf988a GraphicsServices`GSEventRun + 103 
frame #196445: 0x00aa6626 UIKit`UIApplicationMain + 1163 
frame #196446: 0x00002732 MyApp`main + 130 at main.m:16 
frame #196447: 0x000026a5 MyApp`start + 53 

有沒有人對此有何建議?謝謝。

乾杯, Gaz。

+0

這必須發生在你的代碼中的其他地方,因爲我已經使用了你的代碼,它對我來說工作得很好。 – 2012-08-15 15:49:28

+0

你對可達性有什麼特別的要求嗎?這個對UIAccessibility框架的調用對我來說似乎很奇怪。 – 2012-08-15 16:30:35

+0

如果關閉輔助功能,這仍然會崩潰嗎? – 2012-08-15 17:29:53

回答