Post

Replies

Boosts

Views

Activity

Reply to Interface Builder changes x, y, width and height values randomly.
I still have this problem. Unfortunately I haven't found a solution. In all projects, values are changed randomly from the Interface Builder when I change something in the storyboard. I still do not know why. I thought it might be the resolution of the connected monitor, because of the scaling. But it also happens with the MacBook only, without a second monitor connected. After I change something in the storyboard, I always have to manually synchronize the files with a text comparison program to undo the unwanted changes. I could of course program the whole design in source code. Unfortunately, that is a lot of work. The apps have been working for years with the design in Interface Builder and only small adjustments are made in the source code when the device is rotated, for example. I don't want to move everything to the source code now. It would be nice to find the cause and fix it so everything can be done reliably in Interface Builder again. Unfortunately, I marked this topic as solved too early. The accepted answer isn't the solution to the problem, but I can't change that now.
Jan ’23
Reply to On UINavigationBar the leftBarButtonItem and rightBarButtonItem of the UINavigationItem are placed incorrectly on iOS 16
Unfortunately, the two buttons of UIBarButtonItem are also placed incorrectly in the empty test project under iOS 16 if I do everything as in the real project. I add the view of a second UIViewController to the main view and then create the UINavigationBar on top of the second UIViewController's view. It worked fine until iOS 15.5. Unfortunately not with iOS 16. Does anyone know how I can fix the problem? UIEdgeInsets safeAreaInsets = self.view.superview.safeAreaInsets; secondViewController.view.frame = CGRectMake(safeAreaInsets.left, safeAreaInsets.top, self.view.frame.size.width - safeAreaInsets.left - safeAreaInsets.right, self.view.frame.size.height - safeAreaInsets.top - safeAreaInsets.bottom); secondViewController.view.backgroundColor = [UIColor darkGrayColor]; [self.view addSubview:secondViewController.view]; UINavigationBar *navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, secondViewController.view.frame.size.width, 44)]; [secondViewController.view addSubview:navigationBar]; UINavigationItem *navigationItem = [[UINavigationItem alloc] init]; navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:nil]; navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:nil]; [navigationBar pushNavigationItem:navigationItem animated:NO]; With the code below it looks good even with iOS 16, but I really need the first method as in the code above. UIEdgeInsets safeAreaInsets = self.view.superview.safeAreaInsets; secondViewController.view.backgroundColor = [UIColor whiteColor]; UINavigationBar *navigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, safeAreaInsets.top, secondViewController.view.frame.size.width, 44)]; [secondViewController.view addSubview:navigationBar]; UINavigationItem *navigationItem = [[UINavigationItem alloc] init]; navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:nil]; navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:nil]; [navigationBar pushNavigationItem:navigationItem animated:NO]; secondViewController.modalPresentationStyle = UIModalPresentationFullScreen; [self presentViewController:secondViewController animated:NO completion:nil];
Sep ’22
Reply to On UINavigationBar the leftBarButtonItem and rightBarButtonItem of the UINavigationItem are placed incorrectly on iOS 16
I have now made an empty test project where I do nothing else than add the two UIBarButtonItems to the UINavigationBar in the source code and it is displayed correctly under iOS 16. So the problem is not with the iOS 16 but with my source code in a specific project. It's just weird that it shows up correctly on iOS 15.5. Unfortunately I haven't found the cause of the wrong placement of the buttons in my project yet.
Sep ’22