2011-10-09 2 views
1

나는 지금 몇 주 동안 찾고 있었고, Tab Bar app에 테이블 뷰를 추가하는 방법을 보여주는 Xcode 4에 대한 튜토리얼을 찾으려고 노력하지 않았다. 나는 네가 나를 올바른 방향으로 인도 할 수 있는지 궁금해했다.Tab Bar App의 테이블 뷰

감사

+0

에 그들에게 TabBar의 항목을 추가해야합니다,하지만 도움 : HTTP : //www.youtube.com/watch?v=LBnPfAtswgw –

답변

2

당신은 탭 표시 줄에 UIViewControllers를 추가하기 때문에 모든 TabBarController 튜토리얼해야한다. 테이블보기의 경우 UITableViewController를 작성하기 만하면됩니다. 탭 막대 컨트롤러 또는 다른보기 컨트롤러에 추가 할 수 있어야합니다. 예를 들어 navigationController가있는 TabBar를 수행하는 다른 자습서를 찾은 경우 ... 튜토리얼의 navigationController 부분을 UITableViewController로 간단하게 바꿉니다. 또한 UItableViewControllers에 대한 많은 문서와 자습서가 있습니다.

예를 들어, 앱 위임자 didfinishLaunchingWithOptions에서이 코드를 보면. 이것에 대한 Pior는 MyTableViewController (UITableViewController)와 다른 UIViewController를 만들었습니다.

// View Controllers for tabController - could be UItableViewControllers or any 
// other UIViewController. You will add this to the tabController 
NSMutableArray *viewControllers = [[NSMutableArray alloc] init]; 

MyTableViewController *myTable = [[MyTableViewController alloc] initWithNibName:@"MyTableViewController" bundle:nil]; 
[viewControllers addObject:myTable]; 

SomeOtherUIViewController *other = [[SomeOtherUIViewController alloc] initWithNibName:@"SomeOtherUIViewController" bundle:nil]; 
[viewControllers addObject:other];  

// add the UIViewControllers to the tabController 
[tabController setViewControllers:viewControllers]; 

// add tabbar and show 
[[self window] addSubview:[tabController view]]; 
[self.window makeKeyAndVisible]; 
return YES; 

그리고 당신은 TabBar의 추가하는 뷰 컨트롤러의 각

, 당신이 xcode4 아니라 자신의 초기화

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) 
    { 
     UITabBarItem *barItem = [[UITabBarItem alloc] 
          initWithTitle:@"Progress" 
          image:[UIImage imageNamed:@"report.png"] tag:2]; 

     [self setTabBarItem:barItem]; 
     [barItem release]; 
    } 
    return self; 
} 
관련 문제