2009-09-08 4 views
0

J'ai un UIViewController qui contient une sous-vue et un UIToolbar. J'essaye d'ajouter un autre UIViewController contenant un MKMapView comme une sous-vue, mais il ne redimensionne pas correctement et par conséquent, la carte chevauche la barre d'outils. Qu'est-ce que je fais mal?Pourquoi mon UIView ne se redimensionne-t-il pas correctement dans la sous-vue de mon UIViewController?

 
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 
    [DebugLogger writeLog:@"Initializing RootViewController"]; 
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { 
     // Custom initialization 
     self.title = @"Root View"; 

     switchableView.autoresizesSubviews = YES; 
     switchableView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin; 
     switchableView.userInteractionEnabled = YES; 

    } 
    return self; 
} 

- (void)viewDidLoad { 
    [DebugLogger writeLog:@"Calling viewDidLoad in RootViewController"]; 
    [super viewDidLoad]; 

    self.mapView = [[[MapViewController alloc] initWithNibName:@"MapView" bundle:nil] autorelease]; 

    [self.mapView.view setFrame:switchableView.frame]; 

    [switchableView addSubview:self.mapView.view]; 
} 

Répondre

1

Au lieu de cela:

switchableView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;

essayez ceci:

switchableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

Aussi, essayez de autoresizingMask de mapView.view à la même chose.

+0

Cela l'a fait - merci! – mwalsher

Questions connexes