2

我不知道如何将分组样式设置为 UITableView 子类的默认值。我的目标是通过类似的方式将 TableView (ofc) 分组​​。

TableSubclass *myView = (TableSubclass*)some.other.view

这可能吗?我会很感激任何建议。

更新

我有带有自定义 UITabBar 和自定义更多部分的 ios 6 应用程序。

我的“自定义”代码

- (void)viewDidLoad
{
    [super viewDidLoad];
    firstUse=true;
    UINavigationController *moreController = self.moreNavigationController;
    moreController.navigationBar.barStyle = UIBarStyleBlackOpaque;

    self.moreNavigationController.delegate = self;

    if ([moreController.topViewController.view isKindOfClass:[UITableView class]])
    {

         UITableView *view = (UITableView *)moreController.topViewController.view;
        view = [view initWithFrame:view.frame style:UITableViewStyleGrouped];
        UIView* bview = [[UIView alloc] init];
        bview.backgroundColor = [UIColor blackColor];
        [view setBackgroundView:bview];

        moreTableViewDataSource = [[NXMoreTableViewDataSource alloc] initWithDataSource:view.dataSource];
        view.dataSource = moreTableViewDataSource;

    }
}

它在 6 岁以下工作得很好,但在 7 岁以下 UITableView 没有响应,但是当我删除时

[view initWithFrame:view.frame style:UITableViewStyleGrouped];

它再次响应,但我失去了分组风格。

4

1 回答 1

0

Are you sure that the table view is not yet configured? from UITableView Class Reference

When you create a UITableView instance you must specify a table style, and this style cannot be changed

Have a look how to create and configure UITableView.

Generally you use UITableViewController and then in:

- (void)loadView
{
    UITableView *tableView =
     [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]
                                  style:UITableViewStylePlain];
    ...
}
于 2013-10-01T06:32:29.697 回答