Note that there are some explanatory texts on larger screens.

plurals
  1. POUITextView setBorderStyle crashes in iOS 5 Simulator
    text
    copied!<p>I have a strange situation in one view controller where this line crashes in the iOS 5 simulator:</p> <pre><code> // myTextField is created in a NIB myTextField.borderStyle = UITextBorderStyleNone; </code></pre> <p>It's okay in the device (and both device and simulator on iOS 4.3). I've checked the connections in the NIB (even deleted and reconnected). myTextField has a retainCount of 2 at this point in the code. I'm setting other attributes (e.g., "text" and "userInteractionEnabled" prior to this point, and those do not cause a crash.</p> <p>However, if I use this sequence, it does not crash:</p> <pre><code> myTextField.borderStyle = 4; // not a defined border style myTextField.borderStyle = UITextBorderStyleNone; </code></pre> <p>If I use 1, 2, or 3 (defined styles) instead of "4" (an undefined border style), it crashes. "7" works.</p> <p>In my other view controllers, I have similar textViews, and no problem setting the borderStyle to UITextBorderStyleNone.</p> <p>Edit: Here's the backtrace:</p> <pre><code>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 () </code></pre> <p>I notice that the setBorderStyle: is doing a setBackgroundColor:, so changed my code to this:</p> <pre><code>myTextField.backgroundColor = [UIColor clearColor]; myTextField.borderStyle = UITextBorderStyleNone; </code></pre> <p>and the crash no longer happens. But, the background color is being set to "Clear Color" in the NIB.</p> <p>So, the crash is gone, but the mystery of why I must set the background color (even though the NIB is already doing that) remains.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload