2011-02-02 4 views
0

그래서 내 응용 프로그램에는 UITabBarController가 있습니다. 그 중 탭 중 하나는 UINavigationController가 포함 된 UIViewController입니다. 그 안에는 UITableViewController가 있습니다.UITabBarViewController 내에서 UINavigationController 내에서 UITableView의 크기를 조정하는 방법은 무엇입니까?

문제는 어떤 이유로 TableView의 크기가 꺼져 있고 테이블의 아래쪽 항목 중 일부가 TabBar에 의해 가려져 있다는 것입니다. 내가 tableview 크기를 조정할 수 있지만 아무 소용 생각할 수있는 모든 시도했다.

AppDelegate에

tabBarController = [[UITabBarController alloc] init]; 

LogbookViewController *firstVC = [[LogbookViewController alloc] init]; 
PaceCalcViewController *secondVC = [[PaceCalcViewController alloc] init]; 
SettingsTableViewController *thirdVC = [[SettingsTableViewController alloc] init]; 

... 

// Add them as children of the tab bar controller 
tabBarController.viewControllers = [NSArray arrayWithObjects: firstVC, secondVC, thirdVC, nil]; 

LogbookViewController (의 UIViewController의 서브 클래스)

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    navigationController = [[UINavigationController alloc] init]; 
    [self.view addSubview:navigationController.view]; 

    WorkoutListTableViewController *listController = [[WorkoutListTableViewController alloc] init]; 

    listController.managedObjectContext = self.managedObjectContext; 

    [navigationController pushViewController:listController animated:NO]; 
    [listController release]; 
} 

WorkoutListTableViewController (있는 UITableViewController의 서브 클래스) 현재 특히 아무것도에없는 : 여기에 코드의 관련 부분은 그것은 내가 그것에 영향을 미칠 것이라고 생각하지만, 여기에 ViewDidLoad :

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    self.title = @"Workouts"; 

    self.navigationItem.leftBarButtonItem = self.editButtonItem; 

    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"List" style:UIBarButtonItemStyleBordered target:nil action:nil]; 

    self.navigationItem.backBarButtonItem = backButton; 

    NSString *paths = [[NSBundle mainBundle] resourcePath]; 
    NSString *fileName = @"short_bg.png"; 
    NSString *filePath = [paths stringByAppendingPathComponent:fileName]; 
    UIImage *paper = [[UIImage alloc] initWithContentsOfFile:filePath]; 
    UIImageView *paper_bg = [[UIImageView alloc] initWithImage:paper]; 

    self.tableView.backgroundView = paper_bg; 

    [fileName release]; 
    [paper release]; 

    //self.navigationItem.leftBarButtonItem = self.editButtonItem; 

    UIBarButtonItem *addButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(add:)]; 
    self.navigationItem.rightBarButtonItem = addButtonItem; 
    [addButtonItem release]; 

    /*UIBarButtonItem *importButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Import" style:UIBarButtonItemStylePlain target:self action:@selector(importDialogAction:)]; 
    self.navigationItem.leftBarButtonItem = importButtonItem; 
    [importButtonItem release];*/ 
    }  
} 

LogController.view.frame = CGRectMake (뭐든간에) LogbookViewcontroller 또는 self.tableView.frame - CGRectMake (뭐든간에) WorkoutListTableViewController에서 시도했지만 아무 것도 작동하지 않았습니다. 어떤 아이디어? 도움이된다면 더 많은 코드를 게시 할 수 있습니다.

그런 다음 그것을 적절하게 크기 만일, UITabBarController가 직접 탐색 컨트롤러를 추가해야

답변

0

:

tabBarController = [[UITabBarController alloc] init]; 
WorkoutListTableViewController *listController = [[WorkoutListTableViewController alloc] init]; 
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:listController]; 

PaceCalcViewController *secondVC = [[PaceCalcViewController alloc] init]; 
SettingsTableViewController *thirdVC = [[SettingsTableViewController alloc] init]; 

... 

// Add them as children of the tab bar controller 
tabBarController.viewControllers = [NSArray arrayWithObjects: navController, secondVC, thirdVC, nil]; 

당신은보기에 UINavigationController가를 추가 할 첫번째 탭에서보기 컨트롤러를 필요로하지 않습니다, 단지 계속 진행하여 TableViewController를 탐색 컨트롤러의 루트로 추가하고 탐색 컨트롤러를 첫 번째 탭에 추가하십시오.

+0

문제는 탭 제목과 탐색 모음 제목이 달라야한다는 것입니다. 별도로 정의 할 수있는 방법이 있습니까? 또한, 별도의 viewcontroller 만든 이유 중 일부는 모달보기가 나타날 때 탭 표시 줄을 그대로 유지할 수 있도록 표 위의 표시하려면 모달보기 컨트롤러가 있기 때문에 탭 표시 줄 아래에 있기 때문에 때문입니다. 여분의 하위보기없이이 작업을 수행 할 수있는 또 다른 방법이 있습니까? –

관련 문제