그래서 지금은 8 가지보기가있는보기 기반 응용 프로그램을 만들었습니다. 3 개의 뷰에 탭 막대를 표시하고 싶습니다. 이 탭 표시 줄에는 사용자가 3 개의보기로 전환 할 수있는 3 개의 항목이 있습니다.뷰 기반 응용 프로그램에 3 개의 항목이있는 탭 표시 줄 추가
어떻게 그렇게해야합니까? 고마워.
AppDelegate.h
@interface LoginPageAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
UIWindow *window;
LoginPageViewController *viewController;
UITabBarController *tabBarController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet LoginPageViewController *viewController;
@property (nonatomic, retain) IBOutlet IBOutlet UITabBarController *tabBarController;
@end
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
tabBarController = [[UITabBarController alloc] init];
tabBarController.delegate=self;
RequestPage* requestPage = [[RequestPage alloc] init];
UIViewController *RequestPageView = [[UIViewController alloc] initWithRootViewController:requestPage];
StatusPage* statusPage = [[StatusPage alloc] init];
UIViewController *StatusPageView = [[UIViewController alloc] initWithRootViewController:statusPage];
NSArray* controllers = [NSArray arrayWithObjects:RequestPageView, StatusPageView, nil];
tabBarController.viewControllers = controllers;
[window addSubview:tabBarController.view];
[self.window makeKeyAndVisible];
return YES;
}
RequestPage.m
- (id)init {
self.title = @"Request Page";
UIImage* anImage = [UIImage imageNamed:@"3.png"];
UITabBarItem* theItem = [[UITabBarItem alloc] initWithTitle:@"Request Page" image:anImage tag:2];
self.tabBarItem = theItem;
[theItem release];
return self;
}
어떻게 탭 이름과 이미지를 설정합니까? –
나는 나의 대답을 편집했다. 확인해 봐. – Nitish
신속한 답장을 보내 주셔서 감사합니다. 내가 뭘 잘못하고 있는지 전혀 모른다. 이 일에 정말 새로운 것입니다. 내가 한 일로 내 질문을 편집 했으니 제발 한번보세요. 실행 중에 앱이 다운됩니다. –