0

複数のビューを持つタブバーを読み込もうとしていますが、ユーザーが権限を持っている場合にのみ、いくつかのタブを開きたいです。これを処理するデリゲートコールはありますか?tabbardelegateを調べたところ、返送テキストのブール値があるテキストフィールドとは異なり、didSelectItemしかありませんでしたので、返送するかどうかを選択しました。

ありがとう

4

1 に答える 1

1

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item話し合ったものを使用できます。

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item {
    if (item == 2 || item == 3) { //Tab 2 and 3 are protected
        if (!userHasPermission) {
            tabBar.selectedItem = 0; //Make user go to first tab if the user does not have permission.
        }
    }
}

または、特定のアイテムを無効にしたい場合。あなたの中で-viewDidLoad

if (!userHasPermission) {
    UITabBarItem *tabBarItem = [[myTabBar items] objectAtIndex:2];
    [tabBarItem setEnabled:NO];
}
于 2012-09-11T14:56:53.407 に答える