删除[super loadView]时应用冻结 [英] App freeze when I remove [super loadView]

查看:42
本文介绍了删除[super loadView]时应用冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我移除[super loadView]时;该视图将不会显示.超类是UIViewController.

When I remove the [super loadView]; the view wont display. The superclass is UIViewController.

- (void)loadView 
{
    [super loadView];   

    UITableView *tableview = [[UITableView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 367.0f) style:UITableViewStylePlain];
    tableview.dataSource = self;
    tableview.delegate = self;
    self.tableView = tableview;
    [tableview release];

    [self.view addSubview:self.tableView];
}

知道为什么吗?预先感谢!

Any idea why? Thanks in advance!

推荐答案

1)

您对此方法的自定义实现不应调用super.

Your custom implementation of this method should not call super.

2)您必须将 view 属性设置为某些内容.毕竟,此方法称为 loadView :).代替 [self.view addSubview:self.tableView]; 尝试

2) You have to set view property to something. After all this method is called loadView :). Instead of [self.view addSubview:self.tableView]; try

self.view = tableView; 

这篇关于删除[super loadView]时应用冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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