在标签栏应用程序中更改UITableViewController的样式 [英] Change UITableViewController's style in Tab Bar application

查看:50
本文介绍了在标签栏应用程序中更改UITableViewController的样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带4个标签的标签栏iPhone应用程序.在Interface Builder中,我为每个选项卡设置了视图控制器.

I have a tab bar iPhone application with 4 tabs. In the Interface Builder I set view controllers for each tab.

我想将一个UITableViewController的样式从普通样式更改为分组样式.

I want to change style from plain to grouped for one UITableViewController.

我替换init方法是这样的:

I replace init method something like this:

- (id)init
{
    self = [super initWithStyle:UITableViewStyleGrouped];
    if (self != nil) {
        // Initialisation code
    }
    return self;
}

但是没有运气.

没有代码可以调用initWithStyle方法.

There is no code where I can call initWithStyle method.

请在标签栏中建议如何更改UITableViewController的样式.

Please advice how to change style for my UITableViewController in tab bar.

推荐答案

如果通过Interface Builder创建视图,则不会使用init方法.

If your view is created through Interface Builder the init method wont be used.

从*.(nib | xib)加载的对象初始化为:

Objects loaded from a *.(nib|xib) are inited with:

- (id)initWithCoder:(NSCoder *)inCoder;

因此,您可以覆盖它,或者在调用-initWithCoder:之后进行设置不是问题,可以使用:

So you could override that or if doing your setup after -initWithCoder: is called is not a problem you could use:

- (void)awakeFromNib;

来自NSNibAwaking协议.

from the NSNibAwaking protocol.

这篇关于在标签栏应用程序中更改UITableViewController的样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆