를 사용할 때보기는 내가 그렇게 나와 함께 곰이 여전히 새로운 해요 변경되지 않습니다 범용 앱이되어야합니다. 그 후 연결된 뷰 컨트롤러 (각 버전 (iPad, iPhone)를 식별하는 데 도움이되는 1-2 개의 레이블이있는 기본 뷰만 사용)을 사용하여 TabBarController를 프로그래밍 방식으로 만들었습니다. 불을 수행, 제목이 제대로 표시되지만 시각적보기는 전환되지 않습니다 그것은 내가 여기 실종 무엇 기본 MainWindow를 (장치) 각 버전에 대한 .xib 파일에 남아엑스 코드 4 - - 유니버설 응용 프로그램 탭 바 컨트롤러
를 프로그래밍 방식으로 탭을 추가 :..?
- (void) addTabs
{
//set up a local nav controller which we will reuse for each view controller
UINavigationController *localNavigationController;
//create tab bar controller and array to hold the view controllers
tabBarController = [[UITabBarController alloc] init];
NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:2];
//setup the first view controller (Root view controller)
HomeViewController *myViewController;
myViewController = [[HomeViewController alloc] init];
//create the nav controller and add the root view controller as its first view
localNavigationController = [[UINavigationController alloc] initWithRootViewController:myViewController];
// add the new nav controller (with the root view inside of it)
// to the array of controllers
[localControllersArray addObject:localNavigationController];
//release
[localNavigationController release];
[myViewController release];
//setup the second view controller
MapViewController *secondViewController;
secondViewController = [[MapViewController alloc] initWithTabBar];
localNavigationController = [[UINavigationController alloc] initWithRootViewController:secondViewController];
[localControllersArray addObject:localNavigationController];
[localNavigationController release];
[secondViewController release];
tabBarController.viewControllers = localControllersArray;
[localControllersArray release];
}
및 MapViewController.h는 기본입니다. 실제로는 아무 것도 없습니다 :
#import "MapViewController.h"
@implementation MapViewController
- (id)initWithTabBar {
if ([self init]) {
//this is the label of the tab button itself
self.title = @"Map";
//image goes here
//self.tabBarItem.image = [UIImage imageNamed:@"name_gray.png"];
//set the long name show in the Navigation bar at the top
self.navigationItem.title = @"Map View";
}
return self;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"Am I loading?");
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSLog(@"Testing");
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end
이제는 MapViewController.xib 파일은 없지만 MapViewController_iPhone.xib 및 MapViewController_iPad.xib 파일은 있습니다.
공유 할 수있는 코드가 있습니까? – msgambel
여기에 자신을 인용하려고합니다 - _ 이제 MapViewController.xib 파일은 없지만 MapViewController_iPhone.xib 파일과 MapViewController_iPad.xib 파일이 있습니다 ._ - 이것이 문제가 될 수 있습니까? 가능하다면 InterfaceBuilder 사용을 피하고 프로그래밍 방식으로이 작업을 수행하고 싶습니다. – javisrk
이름은 ~ iphone, ~ ipad 및 ***이 아닌 *** _iPhone 및 _IPad입니다. – msgambel