我有一個包含子視圖和UIToolbar的UIViewController。我試圖添加另一個包含MKMapView作爲子視圖的UIViewController,但它沒有正確調整大小,因此地圖與工具欄重疊。我究竟做錯了什麼?爲什麼我的UIView在我的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]; }
這樣做 - 謝謝! – mwalsher 2009-09-11 20:39:45