Resolved Reposition a XIB and content.. not working

Discussion in 'iOS Programming' started by IDMah, May 10, 2014.

  1. IDMah, May 10, 2014
    Last edited: May 11, 2014

    IDMah macrumors 6502

    IDMah

    Joined:
    May 13, 2011
    #1
    Hi all.

    Trying to figure out a way to reposition whole.. XIB ..
    Just want to move it down 20 or so pixels for iPhone 5, but nothing seems to work. On any plain old view works perfectly..

    tried this:
    Code:
     - (void)viewDidLoad {
        [super viewDidLoad];
        pageControlBeingUsed = NO;
        NSLog(@"viewDidLoad");
        // reposition iphone models code //
       CGFloat deltaYYMover = 0.0;
       CGRect deltaViewMover = self.view.frame;
        if (IS_IPHONE5) {
            deltaYYMover = 40.0;
            scalYY = SCALEXFOR5;
        }
        
        deltaViewMover.origin.y = deltaViewMover.origin.y + deltaYYMover;
        self.view.frame = deltaViewMover;
       // other stuff ...  
    )  
    
    Does nothing any ideas?
    Thanks.

    PS. There is a scrollview and two image views in the XIB
     
  2. JohnsonK macrumors regular

    Joined:
    Mar 6, 2014
    #2
    viewDidLoad is too early

    try viewDidLayoutSubviews
     
  3. IDMah thread starter macrumors 6502

    IDMah

    Joined:
    May 13, 2011
    #3
    Thanks for the hint.. this
    Code:
    self.view.frame = deltaViewMover
    code crashes when in viewDidLayoutSubviews..

    So used:
    Code:
    -(void)viewWillAppear:(BOOL)animated{
        //NSLog(@"ViewDidLayout");
      
        // respoition iphone models code //
        CGFloat deltaYYMover = 0.0;
        CGFloat scalYY = SCALEXFOR35;
        CGRect deltaViewMover = self.view.frame;
        if (IS_IPHONE5) {
        deltaYYMover = DELTAYMOVE;
        scalYY = SCALEXFOR5;
        }
     
        deltaViewMover.origin.y = deltaViewMover.origin.y + deltaYYMover;
        self.view.frame = deltaViewMover;
        //self.view.backgroundColor = [UIColor redColor];
        // Reposition ended //
        
    }
    
    Did the trick..
    thanks..
     

Share This Page