ipados 26 and xib

hi, i have an objc ipad application that use xib with zooming for adapt to the screen (until ios18) but with ipad os 26 will be displayed wrong

Answered by DTS Engineer in 844461022

Your code transforms the view using a scale that is hard coded based on a fixed screen size, which I'd strongly discourage. I understand that the project "was born in 2013 with objc and xib," yet the technologies have evolved quite a lot, and you probably don't want to continue to invest your time on your current approach.

As of today, folks are recommended to use Swift + SwiftUI to create their app UI. If switching to a new programming language and UI framework is too aggressive, you might consider adopting Auto Layout in your UIKit + xib + Objective C code, which should make your app automatically adapt different screen sizes and resolutions.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

For folks to help, you might consider providing more context about your question, for example, what Apple APIs you use and how you use them, how you trigger the issue, and what error message you get, if any. Screenshots to show the issue will also help. See tips on writing forums posts, if necessary.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

Accepted Answer

sorry, i just attached sample... this project was born in 2013 with objc and xib, at the moment is over 300 views and use xib with a scaled zoom for adapt to screen size like:

 CGFloat scale=[[UIScreen mainScreen] scale];
    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    CGSize screenSize = CGSizeMake(screenBounds.size.width*scale,screenBounds.size.height*scale);
    
    
    // 2048 e 1536 sono le risoluzioni del retina
    CGFloat scalaX=screenSize.width/2048;
    CGFloat scalaY=screenSize.height/1536;

 if ((screenSize.width==1366) && (screenSize.height==1024))
    {
        scalaX=1.34;
        scalaY=1.34;
    }
    
    if (scalaX<1)
    {
        scalaX=1;
    }
    
    if ((scalaY<1) && (!((screenBounds.size.width*scale==2266) && (screenBounds.size.height*scale==1488))))
    {
        scalaY=1;
    }
    
    CGAffineTransform transform = CGAffineTransformMakeScale(scalaX,scalaY);
    self.view.transform = transform;
code-block

Your code transforms the view using a scale that is hard coded based on a fixed screen size, which I'd strongly discourage. I understand that the project "was born in 2013 with objc and xib," yet the technologies have evolved quite a lot, and you probably don't want to continue to invest your time on your current approach.

As of today, folks are recommended to use Swift + SwiftUI to create their app UI. If switching to a new programming language and UI framework is too aggressive, you might consider adopting Auto Layout in your UIKit + xib + Objective C code, which should make your app automatically adapt different screen sizes and resolutions.

Best,
——
Ziqiao Chen
 Worldwide Developer Relations.

i try to update using autolayout but another issue is the new 3 buttons (close, hide and fullscreen) are over the uibutton inside ma left bar, is it possible create a margin when are showed?

using a function for autoresizing works... in the future what do you suggest me? using swift and objc both, rewritter is too big project

-(void)fixAutoResizingForSubviews:(UIView *)parent {
    
    // 19/06/2025 Simone per ios26
    for (UIView *sub in parent.subviews) {
          if (sub == barMenu) {
              sub.autoresizingMask = UIViewAutoresizingFlexibleWidth; // No flexibleHeight
          } else {
              sub.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
          }
          [self fixAutoResizingForSubviews:sub];
      }
}

i just solved using a new class

#import <UIKit/UIKit.h>

@interface ZoomScrollViewController : UIViewController <UIScrollViewDelegate>
@property (nonatomic, strong) UIScrollView *zoomScrollView;

@end


#import "ZoomScrollViewController.h"
#import <sys/utsname.h>
@implementation ZoomScrollViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // Disabilita gli inset automatici su iOS 11+
    if (@available(iOS 11.0, *)) {
        self.zoomScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }

    // Se stai usando Interface Builder, collega la scrollView via outlet.
    // Altrimenti:
    UIView *orig = self.view;
    UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:orig.frame];
    scroll.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    scroll.delegate = self;
    
    scroll.backgroundColor = [UIColor blackColor];
 
    self.zoomScrollView = scroll;
    [scroll addSubview:orig];
    self.view = scroll;
    
    // Assicurati che lo scrollView non si veda “bianco” dove non c'è contenuto
    self.zoomScrollView.backgroundColor = self.view.backgroundColor;
    // Disabilita inset automatici su iOS 11+
    if (@available(iOS 11.0, *)) {
        self.zoomScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    } else {
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
}
// Helper per recuperare l’identificativo del device
- (NSString*)deviceModelIdentifier {
    struct utsname systemInfo;
    uname(&systemInfo);
    return [NSString stringWithCString:systemInfo.machine
                              encoding:NSUTF8StringEncoding];
}
 
 
- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];

    UIView *content = self.zoomScrollView.subviews.firstObject;
    if (!content) return;

    // 1) Reset
    content.transform = CGAffineTransformIdentity;
    content.frame = CGRectMake(0, 0, 1024, 768);

    // 2) Dimensioni container
    CGSize cSize = self.zoomScrollView.bounds.size;
    CGFloat scaleX = cSize.width / 1024.0;
    CGFloat scaleY = cSize.height / 768.0;

    // 3) Controllo dispositivo
    NSString *modelID = [self deviceModelIdentifier];
    NSLog(@"🔖 Device model: %@", modelID);

    
    NSLog(@"scaleX: %.3f, scaleY: %.3f", scaleX, scaleY);

    BOOL isiPadMiniOrA16 = NO;
    if ([modelID hasPrefix:@"iPad14,1"] ||
        [modelID hasPrefix:@"iPad14,2"] ||
        [modelID hasPrefix:@"iPad14,6"] ||
        [modelID hasPrefix:@"iPad14,7"] ||
        [modelID hasPrefix:@"iPad15,7"]) {
        isiPadMiniOrA16 = YES;
    }

    if (isiPadMiniOrA16) {
        scaleX = 1.152;
        // puoi mantenere scaleY come calcolato sopra, oppure settarlo fisso se necessario
    }
    
    NSLog(@"scaleX: %.3f, scaleY: %.3f", scaleX, scaleY);


    // 4) Applica trasformazione (stretch X)
    content.transform = CGAffineTransformMakeScale(scaleX, scaleY);
    
    // 4b) Centra il contenuto trasformato nella scrollView
    CGSize scaledSize = CGSizeMake(1024 * scaleX, 768 * scaleY);
    self.zoomScrollView.contentSize = scaledSize;

    CGFloat offsetX = (self.zoomScrollView.bounds.size.width  - scaledSize.width)  / 2.0;
    CGFloat offsetY = (self.zoomScrollView.bounds.size.height - scaledSize.height) / 2.0;

    // Assicura che gli offset siano >= 0
    offsetX = MAX(0, offsetX);
    offsetY = MAX(0, offsetY);

    // Posiziona il contenuto al centro
    content.center = CGPointMake(scaledSize.width / 2.0 + offsetX,
                                 scaledSize.height / 2.0 + offsetY);

    // 5) Calcola nuova size del contenuto trasformato

    self.zoomScrollView.contentSize = scaledSize;

    // 6) Centra orizzontalmente solo se necessario
    CGFloat xOff = (scaledSize.width - cSize.width) / 2.0;
    [self.zoomScrollView setContentOffset:CGPointMake(xOff, 0) animated:NO];

    // 7) Disattiva lo zoom dinamico della scrollView
    self.zoomScrollView.minimumZoomScale = 1.0;
    self.zoomScrollView.maximumZoomScale = 1.0;
    self.zoomScrollView.zoomScale = 1.0;
}
@end
code-block

with this tricks works in ios18.5 and 26

ipados 26 and xib
 
 
Q