UITableView子类,其默认样式已分组

时间:2013-10-01 01:24:43

标签: ios objective-c cocoa-touch uitableview

我不知道如何将分组样式设置为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];

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

1 个答案:

答案 0 :(得分:0)

您确定尚未配置表格视图吗? 来自UITableView Class Reference

  

创建UITableView实例时,必须指定表格样式,   并且这种风格无法改变

了解如何创建和配置 UITableView

通常,您使用UITableViewController,然后使用:

- (void)loadView
{
    UITableView *tableView =
     [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]
                                  style:UITableViewStylePlain];
    ...
}
相关问题