5

UINavigationController을 포함하는 UITabBarController이 있습니다.UITabBar에 의해 부분적으로 숨겨진 UITableView

self.voucherTableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain]; 
self.voucherTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth; 

그러나,의 UITabBar가 UITableView 중첩되어 다음과 같이 볼 수 UIViewController 내에서, 나는 프로그램 적 UITableView을 만드는거야.

[[UIScreen mainScreen] applicationFrame]의 높이를 출력 할 때 460.00을 반환하지만 367.00이어야합니다.

Interface Builder에서 뷰의 높이를 자동으로 367.00으로 설정하는 'Simulated Metrics'를 사용하고 있습니다.

필자가 시도한 것이 무엇이든 상관없이 필자가 필요로하는 367.00 높이를 얻지 못한다고 생각합니다. 임시 수정으로

, 나는이 작동하지 않는 이유는 운동 좋을 것 있도록이 정말 좋지 않은 수동 UITableView의 프레임을 설정 한 :

self.voucherTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 367) style:UITableViewStylePlain]; 
+0

아마도 tableView의 autoSizingMasks를 확인해야합니다. – ender

+0

'autoresizingMask' 값을 설정 한 것으로 원래 게시물을 업데이트했습니다. –

답변

4

당신이해야 [[UIScreen mainScreen] applicationFrame] 대신에 self.view.bounds를 사용하십시오. 마지막으로 self.view.bounds가 전체 화면 프레임을 리턴하므로 self.view.bounds는 사용자가 찾고있는 것처럼 보이는 경계를 제공합니다.

+0

self.view.bounds.size.height 값을 출력하려고 시도하고 다시 460.00을 반환했습니다. –

+2

어디에서 그렇게하려고합니다. 업데이트 될 예정 - (void) viewDidAppear : (BOOL) animated; (어쩌면 - (void) viewWillAppear : (BOOL) animated; 또한 확실하지는 않습니다.) – Ariel

+0

알아 두어야 할 또 다른 사항은 wantsFullScreenLayout 속성입니다. UIViewController에 대해 YES로 설정하면 탭 막대를 고려하지 않고 뷰를 자동으로 업데이트합니다. – Ariel

2

당신은 UITabBarControllerUINavigationController 인스턴스를 추가하고 당신의 인생을 많이 쉽게해야 UINavigationController 인스턴스의 rootViewController 속성에 테이블 뷰 컨트롤러를 추가해야합니다.

간단한 예로, 빈 창 기반 응용 프로그램을 만듭니다 (템플릿을 사용하면 실제로 혼동하는 것보다 훨씬 혼란 스럽습니다).

UIViewController/UITableViewController 하위 클래스를 프로젝트에 추가 한 다음이 코드를 프로젝트 설정 가이드로 사용하십시오. 이 코드는 AppDelegate에 클래스에 다음 BrowserViewController 위의 코드 샘플에서

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    // create our table view controller that will display our store list  
    StoresViewController *storeListController = [[StoresViewController alloc] init]; 


    // create the navigation controller that will hold our store list and detail view controllers and set the store list as the root view controller 
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:storeListController]; 
    [navController.tabBarItem setTitle:@"TableView"]; 
    [navController.tabBarItem setImage:[UIImage imageNamed:@"cart.png"]]; 


    // create our browser view controller  
    BrowserViewController *webBrowserController = [[BrowserViewController alloc] init]; 
    [webBrowserController.tabBarItem setTitle:@"WebView"]; 
    [webBrowserController.tabBarItem setImage:[UIImage imageNamed:@"web.png"]]; 

    // add our view controllers to an array, which will retain them 
    NSArray *viewControllers = [NSArray arrayWithObjects:navController, webBrowserController, nil]; 


    // release these since they are now retained 
    [navController release]; 
    [storeListController release]; 
    [webBrowserController release]; 


    // add our array of controllers to the tab bar controller 
    UITabBarController *tabBarController = [[UITabBarController alloc] init]; 
    [tabBarController setViewControllers:viewControllers]; 


    // set the tab bar controller as our root view controller  
    [self.window setRootViewController:tabBarController]; 


    // we can release this now since the window is retaining it 
    [tabBarController release]; 


    [self.window makeKeyAndVisible]; 

    return YES; 
} 

UIViewController의 서브 클래스이며, StoresViewController 클래스는 UITableViewController의 서브 클래스입니다. UITabBarControllerUINavigationController 인스턴스는 프로그래밍 방식으로 만들어지고 창에 추가됩니다.

UITableViewController 클래스를 서브 클래스 화하면 프로그래밍 방식으로 UITableView 인스턴스를 생성하지 않아도되고 필요한 대부분의 항목을 가져 오는 것을 피할 수 있습니다.

[self.navigationController pushViewController:YourDetailViewControllerInstance animated:YES]; 

이 당신을 위해 UINavigationController 인스턴스의 뷰 계층에 상세 뷰 UIViewController 서브 클래스를 추가합니다 : 당신이 UINavigationController 인스턴스의 스택에 상세보기를 밀어해야하는 경우

, 당신은 단지 다음과 유사한 사용 뭔가를 전환을 애니메이션화합니다.

많은 컨트롤러가 있지만,이 방법을 사용하면 뷰에서 크기 조정을 관리하고 툴바/탐색 모음을 모두 고려하여 많은 문제를 피할 수 있습니다.

관련 문제