我在這條線中的iOS 5模擬器崩潰一個視圖控制器一種奇怪的情況:的UITextView setBorderStyle崩潰在IOS 5模擬器
// myTextField is created in a NIB
myTextField.borderStyle = UITextBorderStyleNone;
它在裝置好(和器件和模擬器上的iOS 4.3 )。我已經檢查了NIB中的連接(甚至刪除並重新連接)。 myTextField在代碼中此時的retainCount爲2。我設置其他屬性(例如,「文本」和「userInteractionEnabled」之前這一點,而那些不導致崩潰
但是,如果我用這個順序,它不會崩潰。
myTextField.borderStyle = 4; // not a defined border style
myTextField.borderStyle = UITextBorderStyleNone;
如果我使用1,2,或3(定義的樣式),而不是 「4」(未定義的邊界樣式),它崩潰。 「7」 的工作原理。
在我的另一視圖控制器,I具有相似textViews ,並沒有問題的borderStyle設置爲UITextBorderStyleNone。
編輯:這是ba cktrace:
Thread 1, Queue : (null)
#0 0x01e0609b in objc_msgSend()
#1 0x005c1c22 in -[UIView(Hierarchy) _setBackgroundColor:]()
#2 0x005c3a06 in -[UIView(Rendering) setBackgroundColor:]()
#3 0x0063eab7 in -[UITextField setBackgroundColor:]()
#4 0x0063e1b6 in -[UITextField setBorderStyle:]()
#5 0x000c23e6 in -[DutyEditViewController viewWillAppear:] at /Users/jeff/Applications/iPhone/MyApp/Classes/DutyEditViewController.m:197
#6 0x00651fbf in -[UIViewController _setViewAppearState:isAnimating:]()
#7 0x0065221b in -[UIViewController __viewWillAppear:]()
#8 0x006524c3 in -[UIViewController beginAppearanceTransition:animated:]()
#9 0x00662b71 in -[UINavigationController _startTransition:fromViewController:toViewController:]()
#10 0x006633df in -[UINavigationController _startDeferredTransitionIfNeeded]()
#11 0x00663986 in -[UINavigationController pushViewController:transition:forceImmediate:]()
#12 0x0c894dbd in -[UINavigationControllerAccessibility(SafeCategory) pushViewController:transition:forceImmediate:]()
#13 0x006635a4 in -[UINavigationController pushViewController:animated:]()
#14 0x000bf99a in -[DutiesTableViewController tableView:didSelectRowAtIndexPath:]()
#15 0x0061a71d in -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:]()
#16 0x0061a952 in -[UITableView _userSelectRowAtPendingSelectionIndexPath:]()
#17 0x0025386d in __NSFireDelayedPerform()
#18 0x020dc966 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__()
#19 0x020dc407 in __CFRunLoopDoTimer()
#20 0x0203f7c0 in __CFRunLoopRun()
#21 0x0203edb4 in CFRunLoopRunSpecific()
#22 0x0203eccb in CFRunLoopRunInMode()
#23 0x0258a879 in GSEventRunModal()
#24 0x0258a93e in GSEventRun()
#25 0x0058aa9b in UIApplicationMain()
#26 0x0006117d in main()
#27 0x00002c65 in start()
我注意到setBorderStyle:是做一個setBackgroundColor:,所以改變了我的代碼如下:
myTextField.backgroundColor = [UIColor clearColor];
myTextField.borderStyle = UITextBorderStyleNone;
和碰撞吸能不再發生。但是,NIB中的背景顏色被設置爲「清除顏色」。因此,崩潰消失了,但爲什麼我必須設置背景顏色(即使NIB已經這樣做)仍然存在的奧祕。
感謝回溯;請通過bugreporter.apple.com提交一個錯誤,並附上崩潰版本的應用程序的二進制文件W /重現崩潰的說明。 – bbum