iphone 앱의 경우 프로그래밍 방식으로 탭보기를 만들려면 어떻게해야합니까? 좋은 자습서 링크 나 예제를 제공하여 도움을받을 수 있습니까? 우리가 TabBar의를 만들어야 할 방법Objective-C를 사용하여 프로그래밍 방식으로 탭보기를 만드는 방법
답변
그것은 UITabBarController 통해의 UITabBar를 작성하는 것은 매우 간단하다. 다음 예제는 AppDelegate 클래스 내에서 작동해야합니다.
앱 위임 인터페이스
첫째, 인터페이스 내에서, 우리는 우리의 UITabBarController을 정의 할 수 있습니다.
UITabBarController *tabBarController;
앱 위임 구현
그런 다음, 구현 파일의 application:didFinishLaunchingWithOptions:
방법 내에서, 우리는 우리의 탭 표시 줄 컨트롤러를 초기화합니다.
// Initialise our tab bar controller
UITabBarController *tabBarController = [[UITabBarController alloc] init];
다음으로, 탭 표시 줄 컨트롤러에 추가 할보기 컨트롤러를 만들어야합니다. 탭의 제목/아이콘을 설정하려면이 정보에 몇 가지 정보를 추가해야하지만 마지막에 그 정보로 돌아갑니다. setViewControllers으로
// Create your various view controllers
UIViewController *testVC = [[TestViewController alloc] init];
UIViewController *otherVC = [[OtherViewController alloc] init];
UIViewController *configVC = [[ConfigViewController alloc] init];
: 애니메이션 : 방법은 뷰 컨트롤러의 배열을 필요로, 우리는 배열에 우리의 뷰 컨트롤러를 추가 한 다음를 해제합니다. 합니다 (있는 NSArray로 유지됩니다.)
// Put them in an array
NSArray *viewControllers = [NSArray arrayWithObjects:testVC, otherVC, configVC, nil];
[testVC release];
[otherVC release];
[configVC release];
그리고 단순히 뷰 컨트롤러의 배열로 UITabBarController가를 제공하고 우리의 창에 추가합니다.
// Attach them to the tab bar controller
[tabBarController setViewControllers:viewControllers animated:NO];
// Put the tabBarController's view on the window.
[window addSubview:[tabBarController view]];
마지막으로, 당신은 당신의
dealloc
메소드 내
[tabBarController release];
를 호출해야합니다.
// Create our tab bar item
UITabBarItem *tabBarItem = [self tabBarItem];
UIImage *tabBarImage = [UIImage imageNamed:@"YOUR_IMAGE_NAME.png"];
[tabBarItem setImage:tabBarImage];
[tabBarItem setTitle:@"YOUR TITLE"];
이것은 프로그래밍 방식
UINavigationController *BandNavigationController3;
AudienceSettingsViewController *audienceSettingsViewView =[[AudienceSettingsViewController alloc]initWithNibName:@"AudienceSettingsViewController" bundle:nil];
BandNavigationController3 = [[UINavigationController alloc]initWithRootViewController:audienceSettingsViewView];
BandNavigationController3.tabBarItem.title = @"Settings";
BandNavigationController3.tabBarItem.image = [UIImage imageNamed:@"settings.png"];
[BandNavigationController3.tabBarItem initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:4];
BandNavigationController3.navigationBar.hidden = YES;
[bandTabBarArray addObject:BandNavigationController3];
[BandNavigationController3 release];
[audienceSettingsViewView release];
[tabBarController setViewControllers:bandTabBarArray];
[bandTabBarArray release];
-1을 다음과 같이
보기 컨트롤러 구현 뷰 컨트롤러의 각 내부
은 또한 init 메소드 내에서 탭의 제목과 아이콘을 설정할 수 있습니다 잘못된 형식의 복사 및 붙여 넣기 작업이 잘못되었습니다. –
- 1. 프로그래밍 방식으로 명령 링크를 만드는 방법
- 2. 프로그래밍 방식으로 sqlite 데이터베이스에서 테이블을 만드는 방법
- 3. 프로그래밍 방식으로 SharePoint 사이트에서 폴더를 만드는 방법
- 4. 프로그래밍 방식으로 내비게이션 막대를 만드는 방법
- 5. iphone에서 프로그래밍 방식으로 버튼을 만드는 방법
- 6. 프로그래밍 방식으로 레이아웃 파일을 만드는 방법
- 7. 프로그래밍 방식으로 이미지 모서리를 만드는 방법
- 8. 안드로이드 프로그래밍 방식으로 뷰를 만드는 방법
- 9. TreeView 프로그래밍 방식으로 노드를 만드는 방법
- 10. C#을 사용하여 Exchange 2010 사서함을 프로그래밍 방식으로 만드는 방법
- 11. C를 사용하여 프로그래밍 방식으로 셰어 포인트 탐색 모음을 만드는 방법 #
- 12. HTML로 탭보기를 만들려면 어떻게해야합니까?
- 13. 프로그래밍 방식으로 탭 간 전환
- 14. Quartz & C와 ObjectiveC를 사용하여 이미지를로드하는 것과의 차이점은 무엇입니까?
- 15. transparent 액티비티를 프로그래밍 방식으로 만드는 방법은 무엇입니까?
- 16. Outlook 메일 본문에 프로그래밍 방식으로 테이블을 만드는 방법
- 17. NUnit을 프로그래밍 방식으로 실행하는 방법
- 18. 프로그래밍 방식으로 UITable을 스크롤하는 방법
- 19. 프로그래밍 방식으로 트리거 객체를 만드는 방법은 무엇입니까?
- 20. Xcode를 사용하여 SQLite 데이터베이스에서 프로그래밍 방식으로 인덱스를 만드는 방법은 무엇입니까?
- 21. Django의로드 데이터를 사용하여 프로그래밍 방식으로
- 22. 프로그래밍 방식으로 버튼을 만드는 코드를 어디에 삽입합니까?
- 23. 프로그래밍 방식으로 UIViewController를 만드는 방법은 무엇입니까?
- 24. 프로그래밍 방식으로 스크린 메이트를 만드는 방법은 무엇입니까?
- 25. 프로그래밍 방식으로 아이폰에 CSV 파일을 만드는 방법은?
- 26. 프로그래밍 방식으로 UISplitViewController를 만드는 방법은 무엇입니까?
- 27. 프로그래밍 방식으로 테이블보기를 만드는 방법은 무엇입니까?
- 28. 프로그래밍 방식으로 .ics 파일을 만드는 방법은 무엇입니까?
- 29. 프로그래밍 방식으로 DotNetNuke 페이지를 만드는 방법은 무엇입니까?
- 30. 프로그래밍 방식으로 이미지를 만드는 가장 좋은 방법은
프로그래밍 방식으로 내 tabBarControllers를 만들 때 각 탭마다 navigationController를 만들고 각 navigationController는 rootViewController로 초기화됩니다. NavController가 없기 때문에 네비게이션 스택을 만들 수 없다는 것을 당신의 예제에서 보았습니다. –
@ Wolfgang 나는 네비게이션 스택에 아이템을 밀어 넣거나/pop하고 싶을 것인가에 달려 있다고 생각한다. (내 예제는 매우 기본적인 "접근법"입니다.) –
thnx 많이 작동합니다. – Kiran