Post

Replies

Boosts

Views

Activity

Reply to Crash on iOS 16.2: -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:
Yes I was able to resolve it. So in my case I have a dedicated object as the UITableViewDataSource that sits between the UIViewController and the UITableView. The object that I use as the table view data source implements everything needed to populate the table view data, refreshing it automatically on model changes, etc. The only thing my table view data source doesn't do was provide a UITableView cell in -tableView:cellForRowAtIndexPath: method (instead it asks its delegate for the cell, which is the UIViewController) . My data source object is sort of like UITableViewDiffableDataSource in this way. So what was happening is the UITableView AND the table view data source objects were occasionally outliving the UIViewController. Then when a model change notification is posted my datasource object asked the view controller for the cell in -tableView:cellForRowAtIndexPath: (but the view controller was already deallocated). Never was able to reproduce it in debug mode. I removed the delegate-protocol from my data source object and captured the cell creation code in a block property and I haven't had a crash since.
Topic: UI Frameworks SubTopic: UIKit Tags:
Apr ’23
Reply to UIDeferredMenuElement With Uncached Provider Not Working on Mac Catalyst. Uncached provider block never called and menu displays as "Loading"
Still not fixed in Ventura 13.3. Can you show your code so I can see what's different from mine? I tried using it with a UIButton instead of UIBarButtonItem and then adding it to my NSToolbar with NSUIViewToolbarItem but still not working. The menu just shows a "Loading..." item and the uncached provider block is never called.
Topic: UI Frameworks SubTopic: UIKit Tags:
Apr ’23
Reply to UITextView.scrollRangeToVisible() broken
UITextView -scrollRangeToVisible: wasn't working for me either. I have a UITextView and I'm trying to have it scroll to particular words. In my case I set the scrollEnabled property to NO on the UITextView because I need user scrolling to be disabled. For me the workaround was to set the scrollEnabled property back to YES and set the userInteractionEnabled property to NO. -scrollRangeToVisible: then started working but only sometimes. I had to change the text layout to TextKit1 as mentioned by @alexschecha to get the -scrollRangeToVisible: method to work properly. Unlike -setContentOffset: the -scrollRangeToVisible: method will only work if the scrollEnabled property is YES it seems and it will only work reliably under TextKit1 as far as I can tell. There is still a limitation though. I'd like to scroll the range to the middle of the UITextView. If the range is below the visible region of the UITextView then -scrollRangeToVisible: will scroll it to the bottom. I tried getting the frame for the range myself like so: UITextPosition *beginning = textView.beginningOfDocument; UITextPosition *start = [textView positionFromPosition:beginning offset:range.location]; UITextPosition *end = [textView positionFromPosition:start offset:range.length]; UITextRange *textRange = [textView textRangeFromPosition:start toPosition:end]; CGRect rect = [textView firstRectForRange:textRange]; CGRect finalRect = [textView convertRect:rect fromView:textView.textInputView]; textView.contentOffset = CGPointMake(0.0,finalRect.origin.y-visibleOffetY); And that works... sometimes. Every once and awhile the computed rect from the range will be CGRectNull (range is valid but I get CGRectNull anyway).
Topic: App & System Services SubTopic: Core OS Tags:
May ’23