Post

Replies

Boosts

Views

Activity

Reply to Xcode 15 Beta 5 breaks existing RealityKitContentBundle
Guys. I fix this issue by this change in my code. Previously, I was using ModelEntity to load my .usda, and it works fine with beta 2. In beta 5, loading .usda with ModelEntity is not working. So I change it to Entity and everything works fine. // changing ModelEntity to Entity // if let scene = try? await ModelEntity(named: sceneName, in: realityKitContentBundle) { if let scene = try? await Entity(named: sceneName, in: realityKitContentBundle) { content.add(scene) }
Aug ’23
Reply to iOS 16 unexpected rotation behaviour
I had a similar problem. Calling setViewController:animated: of UINavigationController to replace topViewController (which is landscape) with a new landscape viewController makes the viewController try to rotate to portrait first, then suddenly change to landscape. Here is the code to reproduce this bug. #import "ViewController.h" @interface UINavigationController (Replace) - (void)replaceTopWithViewController:(UIViewController *)viewController               animated:(BOOL)animated; - (void)replaceViewControllersInRange:(NSRange)range          withViewControllers:(NSArray<UIViewController *> *)viewControllers                animated:(BOOL)animated; @end @implementation UINavigationController (Replace) - (void)replaceViewControllersInRange:(NSRange)range          withViewControllers:(NSArray<UIViewController *> *)viewControllers                animated:(BOOL)animated {   NSMutableArray *VCs = [self.viewControllers mutableCopy];   [VCs replaceObjectsInRange:range withObjectsFromArray:viewControllers];   [self setViewControllers:[VCs copy] animated:animated]; } - (void)replaceTopWithViewController:(UIViewController *)viewController animated:(BOOL)animated {   [self replaceViewControllersInRange:NSMakeRange(self.viewControllers.count - 1, 1)           withViewControllers:@[viewController]                 animated:animated]; } @end @implementation NavigationController - (BOOL)shouldAutorotate {   return [self.topViewController shouldAutorotate]; } - (UIInterfaceOrientationMask)supportedInterfaceOrientations {   return [self.topViewController supportedInterfaceOrientations]; } - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {   return [self.topViewController preferredInterfaceOrientationForPresentation]; } @end @interface ThirdViewController : UIViewController @end @implementation ThirdViewController - (BOOL)shouldAutorotate {   return YES; } - (void)viewDidLoad {   [super viewDidLoad];   self.view.backgroundColor = UIColor.redColor; } - (UIInterfaceOrientationMask)supportedInterfaceOrientations {   return UIInterfaceOrientationMaskLandscapeRight; } @end @interface SecondViewController : UIViewController @end @implementation SecondViewController - (BOOL)shouldAutorotate {   return YES; } - (UIInterfaceOrientationMask)supportedInterfaceOrientations {   return UIInterfaceOrientationMaskLandscapeRight; } - (void)viewDidAppear:(BOOL)animated {   dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{     ThirdViewController *controller = [[ThirdViewController alloc] init];     [self.navigationController replaceTopWithViewController:controller animated:YES];   }); } @end @interface ViewController () @end @implementation ViewController - (UIInterfaceOrientationMask)supportedInterfaceOrientations {   return UIInterfaceOrientationMaskPortrait; } - (void)viewDidLoad {   [super viewDidLoad];   self.view.backgroundColor = UIColor.whiteColor; } - (void)viewDidAppear:(BOOL)animated {   dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{     SecondViewController *controller = [[SecondViewController alloc] init];     [self.navigationController pushViewController:controller animated:YES];   }); } @end
Aug ’22