5

UINavigationControllerを含むUITabBarControllerがあります。目に見えるUIViewControllerの中で、次のように私はプログラム的にUITableViewを作成しています:UITabBarによって部分的に隠されたUITableView

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

しかし、UITabBarはUITableViewを重ねています。

[[UIScreen mainScreen] applicationFrame]の高さを出力すると、460.00が返されますが、367.00になります。

Interface Builderでは、ビューの高さを自動的に367.00に設定する 'Simulated Metrics'を使用しています。

何か私は、私が必要とする367.00の高さを得るために私が何をしようとしても見逃しています。

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

tableViewのautoSizingMasksを確認する必要があります – ender

+0

オリジナルの投稿を 'autoresizingMask'の値に設定して更新しました。 –

答えて

4

あなたがすべき:これが機能しない理由、動作するようにいいだろうので

一時修正として、私は手動でUITableViewの枠を設定して、これは本当に理想的ではありません[[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のサブクラスです。 UITabBarControllerおよびUINavigationControllerのインスタンスがプログラムによって作成され、ウィンドウに追加されます。

UITableViewControllerクラスをサブクラス化すると、UITableViewインスタンスをプログラムで作成しなくても、ほとんどの必要なものをすべて取得する必要がなくなります。

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

このあなたのためUINavigationControllerインスタンスのビュー階層に詳細ビューUIViewControllerサブクラスを追加します:あなたはUINavigationControllerインスタンスのスタックに詳細ビューをプッシュする必要がある場合

、あなただけのこれに似た使用の何かを持っていますトランジションをアニメートします。

多くのコントローラがこれに含まれていますが、この方法ではサイズ変更を管理し、ツールバー/ナビゲーションバーを単独で考慮に入れることができるので、多くの問題が回避されます。

関連する問題