Search code examples
objective-cios5uiviewcontrollerresizereloaddata

ReloadData in UIViewController


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.


Solution

  • Try

    [self.view setNeedsDisplay];