Post

Replies

Boosts

Views

Activity

TVUIKit Lockup views in a Storyboard terminating at runtime. Anything I need to do?
Working on a new tvOS app, and after creating a few Views in a Storyboard I found an opportunity to use one of the handy TVLockupView subclasses. Specifically, TVCardView. So I dragged one in to a UICollectionViewCell. Problem is, at runtime, the app terminates when unarchiving the Storyboard. ** Terminating app due to uncaught exception 'NSInvalidUnarchiveOperationException', reason: 'Could not instantiate class named TVCardView because no class named TVCardView was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the correct target)' As a sanity check I created a new project from scratch, and see the same issue adding any TVUIKit views to the Storyboard. If I view the Storyboard in the source editor, I do see capability name="TVUIKit controls" minToolsVersion="10.2"/. But I suspect that that only populates the Library with the TVUIKit views. The files are both definitely part of the correct target, and my source code is my Storyboard. Anything else I can do here or do I just need to create all of my TVUIKit views in code? (FB9110528)
1
0
1k
May ’21
"Jump to Definition" not working consistently with target/action pattern
I've inherited a large project. Digging around the codebase has been tough because "Jump To Definition" isn't working consistently. The codebase is almost entirely in Objective-C, and I'm seeing usage of the target-action pattern like: // ViewController1.m (void)viewDidLoad { 	[super viewDidLoad]; 	UIButton *button = [UIButton new]; 	[button addTarget: self action:@selector(selected) forControlEvents: UIControlEventTouchUpInside]; } (void)selected { 		NSLog(@"selected in View Controller 1"); } When I command + control + click on the "selected" method name inside of the @selector attribute, it will jump to the definition of the wrong method. The incorrect method has the same signature: it is named "selected" and takes no arguments. But that implementation is in an unrelated class in a different source file. My first instinct was that this is a bug when using @selector, but I was not able to duplicate in a simple sample project - two source files that have a selector with the same name will behave as expected when trying to Jump to Definition. I thus believe this to be an issue due to the nature of the inherited project - it's very large, and there are over 200 existing warnings. It takes a very long time to index. I wonder if that has anything to do with it? Are there any tips for dealing with "Jump to Definition" not working in a legacy project? I plan on fixing the warnings at some point, but if there's another thing I can do in the meantime it would be helpful as I familiarize myself with the code.
1
0
1.8k
Feb ’22
How do I properly mix SwiftUI Views with Auto Layout Constraint animations?
I have a SwiftUI View I've introduced to a UIKit app, using UIHostingController. The UIView instance that contains the SwiftUI view is animated using auto layout constraints. In this code block, when a view controller's viewDidAppear method I'm creating the hosting controller and adding its view as a subview of this view controller's view, in addition to doing the Container View Controller dance. override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) let hostingViewController = UIHostingController(rootView: TestView()) hostingViewController.view.translatesAutoresizingMaskIntoConstraints = false addChild(hostingViewController) view.addSubview(hostingViewController.view) let centerXConstraint = hostingViewController.view.centerXAnchor.constraint(equalTo: view.centerXAnchor) let topConstraint = hostingViewController.view.topAnchor.constraint(equalTo: view.topAnchor) widthConstraint = hostingViewController.view.widthAnchor.constraint(equalToConstant: 361) heightConstraint = hostingViewController.view.heightAnchor.constraint(equalToConstant: 342) NSLayoutConstraint.activate([centerXConstraint, topConstraint, widthConstraint, heightConstraint]) hostingViewController.didMove(toParent: self) self.hostingViewController = hostingViewController } I add a button to the UI which will scale the UIHostingViewController by adjusting its height and width constraints. When it's tapped, this action method runs. @IBAction func animate(_ sender: Any) { widthConstraint.constant = 120.3 heightConstraint.constant = 114.0 UIView.animate(withDuration: 0.5) { self.view.layoutIfNeeded() } } The problem is, the SwiftUI view's contents "jump" at the start of the animation to the final height, then animate into place. I see this both using UIView.animate the UIKit way, or creating a SwiftUI animation and calling `UIView. What else do I need to add to make this animate smoothly?
1
0
414
Feb ’25