0
votes

I run my app in ios simulator with different simulators for ios 7.0 (Iphone Retina 3.5 inch , Iphone Retina 4 inch , Iphone Retina 4 inch 64-bit) and i check the device bounds. According to the bounds i place the components of each viewcontroller to specific positions. Although today i tried to run my app in different version of ios(ios 6.0) and items seem to be repositioned by own at wrong positions although screen has the same bounds. Here is the method that handles the position of components.

     if(self.view.bounds.size.height==480){

        self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background2.png"]];


        float positionScrollBar= self.view.bounds.size.height-72;

        _scroller.frame = CGRectMake(0, positionScrollBar, 320, 72);

        _scroller.contentSize = CGSizeMake(450, 0);

        _scroller.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"toolbar.png"]];

        [self.logo setFrame:CGRectMake(30,100,260,260)];

        int xCoord=10;
        int yCoord=10;
        int buttonWidth=50;
        int buttonHeight=50;
        int buffer = 22;

        self.grBtn.frame = CGRectMake(xCoord,yCoord, buttonWidth, buttonHeight);
        xCoord += buttonWidth + buffer;

        self.enBtn.frame = CGRectMake(xCoord,yCoord, buttonWidth, buttonHeight);
        xCoord += buttonWidth + buffer;

        self.frBtn.frame = CGRectMake(xCoord,yCoord, buttonWidth, buttonHeight);
        xCoord += buttonWidth + buffer;

        self.gerBtn.frame = CGRectMake(xCoord,yCoord, buttonWidth, buttonHeight);
        xCoord += buttonWidth + 10;

        self.rightArrowBtn.frame = CGRectMake(xCoord,15, 27, 44);
        xCoord += buttonWidth-4;

        self.leftArrowBtn.frame = CGRectMake(xCoord,15, 27, 44);
        xCoord += buttonWidth;

        self.ispBtn.frame = CGRectMake(xCoord,yCoord, buttonWidth, buttonHeight);
        xCoord += buttonWidth + buffer;

        self.ruBtn.frame = CGRectMake(xCoord,yCoord, buttonWidth, buttonHeight);
        xCoord += buttonWidth + buffer;

        self.itBtn.frame = CGRectMake(xCoord,yCoord, buttonWidth, buttonHeight);

        xCoord += buttonWidth + 55;

        _scroller.contentSize = CGSizeMake(xCoord, 0);


        self.rightArrowBtn.hidden=NO;
        self.leftArrowBtn.hidden=NO;




    }
    else
    {
        self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background2.png"]];


        float positionScrollBar= self.view.bounds.size.height-72;

        _scroller.frame = CGRectMake(0, positionScrollBar, 320, 72);

        _scroller.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"toolbar.png"]];

        [self.logo setFrame:CGRectMake(20,150,280,280)];

        int xCoord=10;
        int yCoord=10;
        int buttonWidth=50;
        int buttonHeight=50;
        int buffer = 22;

        self.grBtn.frame = CGRectMake(xCoord,yCoord, buttonWidth, buttonHeight);
        xCoord += buttonWidth + buffer;

        self.enBtn.frame = CGRectMake(xCoord,yCoord, buttonWidth, buttonHeight);
        xCoord += buttonWidth + buffer;

        self.frBtn.frame = CGRectMake(xCoord,yCoord, buttonWidth, buttonHeight);
        xCoord += buttonWidth + buffer;

        self.gerBtn.frame = CGRectMake(xCoord,yCoord, buttonWidth, buttonHeight);
        xCoord += buttonWidth + 10;

        self.rightArrowBtn.frame = CGRectMake(xCoord,15, 27, 44);
        xCoord += buttonWidth-4;

        self.leftArrowBtn.frame = CGRectMake(xCoord,15, 27, 44);
        xCoord += buttonWidth;

        self.ispBtn.frame = CGRectMake(xCoord,yCoord, buttonWidth, buttonHeight);
        xCoord += buttonWidth + buffer;

        self.ruBtn.frame = CGRectMake(xCoord,yCoord, buttonWidth, buttonHeight);
        xCoord += buttonWidth + buffer;

        self.itBtn.frame = CGRectMake(xCoord,yCoord, buttonWidth, buttonHeight);
        xCoord += buttonWidth + 55;

        _scroller.contentSize = CGSizeMake(xCoord, 0);


        self.rightArrowBtn.hidden=NO;
        self.leftArrowBtn.hidden=NO;

    }

I do not use Auto-Layout and i can not use it.

Any advice is appreciated.

2

2 Answers

1
votes

When you say 'repositioned' do you mean on the y-axis?

I suggest you look at iOS 6/7 deltas. You could start here: Interface Builder: What are the UIView's Layout iOS 6/7 Deltas for?

1
votes

In iOS7, UINavigationBar isTranslucent = YES by default, that causes a 20px difference downwards. You can write a category to make it isTranslucent = NO, you can use iOS6/7 deltas as Andy said, or you can manually setFrame by adding origin.y += 20