2

5つを超えるビューがあるため、「More」ビューコントローラーを備えたタブバー(UITabBarController)アプリケーションがあります。私のアプリケーションの残りの部分は黒の背景と白のテキストを持っており、これに一致するようにこのテーブルをカスタマイズすることができました。ただし、この結果、通常は[その他]テーブルの左側に表示されるタブバーの画像は表示されません(背景が白であるため)。背景が黒のタブバーと同じようにタブバーの画像を表示する方法を見つける必要があります。

例:

黒の背景(非表示の画像)

TabBarControllerをサブクラス化し、「MoreTableView」のデータソースを変更しました。

TabBarController.m

- (void)viewDidLoad {

    [super viewDidLoad];

    UINavigationController *moreController = self.moreNavigationController;

    moreController.navigationBar.barStyle = UIBarStyleBlackOpaque;

    if ([moreController.topViewController.view isKindOfClass:[UITableView class]])
    {
        UITableView *view = (UITableView *)moreController.topViewController.view;
        view.separatorColor = [[UIColor alloc] initWithRed:0.3 green:0.3 blue:0.3 alpha:1.0];    
        view.backgroundColor = [UIColor blackColor];
        view.dataSource = [[MoreTableViewDataSource alloc] initWithDataSource:view.dataSource];
    }
}

MoreTableViewDataSource.m

-(MoreTableViewDataSource *) initWithDataSource:(id<UITableViewDataSource>) dataSource
{
    originalDataSource = dataSource;
    [super init];
    return self;
}


- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section
{
    return [originalDataSource tableView:table numberOfRowsInSection:section];
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [originalDataSource tableView:tableView cellForRowAtIndexPath:indexPath];
    cell.textColor = [[UIColor alloc] initWithRed:1 green:0.55 blue:0 alpha:1.0];
    cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"customAccessory.png"]];
    return cell;
}

よろしくお願いします、
ジュリアン

4

2 に答える 2

1

まず、タブバーコントローラーのサブクラスを投稿していただきありがとうございます。私はそれをアプリケーションの書き込みに含め、同じ問題に遭遇しました。

私の解決策は、画像とハイライトされた画像を単純に交換することです。このためには、の方法を変更する必要がありますtableView:cellForRowAtIndexPath:MoreTableViewDataSource.m例:

- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [dataSource tableView:tableView cellForRowAtIndexPath:indexPath];
    UIImageView *imageView = [cell imageView];
    UIImage *image = [imageView image];
    [imageView setImage:[imageView highlightedImage]];
    [imageView setHighlightedImage:image];
    return cell;
}

乾杯、マイケル

于 2009-12-30T18:46:56.503 に答える
1

するのはちょっとmoreController.topViewController.view危険です。

代わりに、通常のアイコンを使用してその他のリストを実行する独自の作成のタブを配置し、通常のナビゲーション コントローラー メソッドを使用してその他のリストの下にある他のタブを開くことをお勧めします。もちろん、タブバーからオーバーフロータブ項目を削除する必要があります。

ただし、これを行うためのよりエレガントな方法があるかもしれません。

于 2009-06-19T08:26:22.247 に答える