0

How can I refresh my views of UIViewController after I resize it? I need a method similar to reloadData in UITableViewController.

Are there other possibility to resize views of UIViewController without reload?

My code is:

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    orientation = toInterfaceOrientation;
    if(orientation==3 || orientation==4)
    {
        heightBoxDimension1 = [GlobalData sharedGlobalData].heightLandscape;
        widthBoxDimension1 = [GlobalData sharedGlobalData].widthLandscapeBig;
        widthBoxDimension2 = [GlobalData sharedGlobalData].widthLandscapeSmall;
    }
    else 
    {
        heightBoxDimension1 = [GlobalData sharedGlobalData].heightPortrait;
        widthBoxDimension1 = [GlobalData sharedGlobalData].widthPortraitBig;
        widthBoxDimension2 = [GlobalData sharedGlobalData].widthPortraitSmall;
    }
    for(UIView* view in self.view.subviews)
    {
        NSLog(@"%.0f %.0f %.0f %.0f ", view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height);
        if(view.frame.size.width >400)
        {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, widthBoxDimension1, heightBoxDimension1)];
            NSLog(@"%.0f %.0f %.0f %.0f ", view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height);
        }
        else
        {
            [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, widthBoxDimension2, heightBoxDimension1)]; 
            NSLog(@"%.0f %.0f %.0f %.0f ", view.frame.origin.x, view.frame.origin.y, view.frame.size.width, view.frame.size.height);
        }
    }
    [self.view setNeedsDisplay];

}

I have a class of global variables, where i put the static dimensions of views, i have two type of view, with the same height but different width. when turn the simulator enter for this method but after change the frame of views, don´t reload these views...

The output of console is:

2012-06-05 10:53:09.309 TemplateiPad2[12561:207] 8 8 752 318 
2012-06-05 10:53:09.309 TemplateiPad2[12561:207] 8 8 752 446 
2012-06-05 10:53:09.309 TemplateiPad2[12561:207] 8 334 372 318 
2012-06-05 10:53:09.309 TemplateiPad2[12561:207] 8 334 372 446 

Do good the re-frame but don´t reload.

Davidin073
  • 991
  • 4
  • 12
  • 25

2 Answers2

0

Try

[self.view setNeedsDisplay];
Mundi
  • 79,884
  • 17
  • 117
  • 140
0

This will do the trick for you!

[self.view setNeedsDisplay]; 
Monolo
  • 18,205
  • 17
  • 69
  • 103
Farrukh Javeid
  • 634
  • 6
  • 25
  • then there might be some detail that you are missing in the description of the question because logically, it should do the trick for your. Can you post the code for the question? How are you resizing the view? – Farrukh Javeid Jun 05 '12 at 07:26
  • oK, I,VE UPLOADED PART OF MY CODE. – Davidin073 Jun 05 '12 at 08:55
  • I am not sure what is the problem but I do not think it requires to use the setNeedsDisplay method. Check if there is any warning about what you are doing or try to debug it with breakpoints, either the control is going in the conditions at all or not. – Farrukh Javeid Jun 06 '12 at 15:54