user469652
user469652

Reputation: 51261

How to make this xib file fill the entire screen of iPhone 6 plus

I would like to use the same nib file for both iPad and iPhone.

I found there are two black bars in the top and bottom when I run the app on iPhone 6 plus. So I found there is a fixed size defined in my xib file, and they are not editable.

How should I make it adapt to different screen size?

Note: * The project doesn't use autolayout and storyboard

enter image description here

Upvotes: 1

Views: 3069

Answers (3)

Tapas Pal
Tapas Pal

Reputation: 7207

On viewWillAppear set frame of your xib file.

swift

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.view.frame = UIScreen.main.bounds
    }

Objective-C

-(void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [[self view] setFrame:[[UIScreen mainScreen] bounds]];
}

Upvotes: 5

Vidhyanand
Vidhyanand

Reputation: 5369

AutoResizing Image

You have to unable all the Auto Resizing masks at XIB

In ur picture, u also need to set Width & Height Auto Resizing masks..So that the xib/view will take the width & Height as per super view or fill the screen.

For more info about Auto Resizing Masks refer below link..

Autoresizing masks programmatically vs Interface Builder / xib / nib

Hope it helps you..

Upvotes: -2

bsarrazin
bsarrazin

Reputation: 4040

There is no way around it, you need to use autolayout and size classes: https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/AboutAdaptiveSizeDesign.html

You can use nib files, that's fine, but autolayout and size classes are unavoidable if you're going to make an app for all devices.

Upvotes: 2

Related Questions