Autorating does not work in xib

I made a simple design in .xib, the deployment goal for my application is iOS 5. My view does not change when I run my application in a simulator or device.

here is a snapshot of my file .xib..

When I try to run my application in the simulator, it works correctly in the 4 "simulator, but it does not change when I run my application in the simulator 3.5". Verified autoreize subview property .

Here is a screenshot of mine Simulaotrs, the first screenshot for 3.5 "and the second for 4" ..

Thanks in advance.

+5
source share
7 answers

, ,
layout

.xib;)

+5

.xib(416 = 480 - 20 ( ) - 44 ( ) enter image description here

416 = 480 - 20 (width for status bar) - 44 (width for nav bar)

, iPhone 5 : enter image description hereenter image description here

, iPhone 5 : enter image description hereenter image description here

+7

, .xib. enter image description here

+3

, . , , , iOS 5, . , iOS 6, iOS 5. , constraints UIView ( , iOS 6 ) .

- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions:

if (![self.window.rootViewController.view respondsToSelector:@selector(constraints)]) {
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_BC_iPhone" bundle:nil];
    UITabBarController *rootController = [storyboard instantiateInitialViewController];
    [self.window setRootViewController:rootController];
}

iOS 6 , . - Storyboard 3,5- , iPhone 5 iOS 6, , , Storyboard 4- .

Storyboard - iOS 6, , 3,5- , .

. , , , , , .

[] , .xib, , . , UIView constraints, NIB (.xib) .

+2

.
UIVIew -, , ( , )
enter image description here

(, ) enter image description here

  • .
+2

Ray WenderLich. autoLayout . , . Autolayout, , View.

+2

, , .

Autolayout, Contraints, , . . scrollview 480, .

Autolayout disabled

In your .h file, make an IBOutlet for your view:

@property (strong, nonatomic) IBOutlet UIView *contentView;

In your .m file, configure like this.

//Add scrollview
UIScrollView *scrollView=(UIScrollView *)self.view;
scrollView.contentSize=self.contentView.frame.size;
[self.view addSubview:self.contentView];

Another work around, allowing you to place your elements wherever you are, with different distances, etc., would be to make two different .xib files and configure it the way you do in ViewController:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
        if([UIScreen mainScreen].bounds.size.height == 568.0)
        {
            //Use iPhone5 VC
            self = [super initWithNibName:@"RootViewController-568h" bundle:nibBundleOrNil];
        }
        else{
            //Use Default VC
            self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        }
    }
    return self;
}

This is if you call your ViewController RootViewController, and thus you will be safe if they decide to expand the screen size to the next iPhone5 or iPhone6. It won’t look great, but at least it won’t cause the app to crash.

+1
source

All Articles