【问题标题】:Anybody know how to solve a "viewDidUnload undeclared" problem?有人知道如何解决“viewDidUnload undeclared”问题吗?
【发布时间】:2010-08-20 23:36:16
【问题描述】:

还有如何解决“预期的';'在'{'令牌之前?下面的代码(来自xcode 3.2.3)

- (void)viewDidUnload {

    self.cheatName = nil;

    self.description = nil;

}

两个错误都在第一行

- (void)viewDidLoad {
    [super viewDidLoad];

    [self.titleLabel setText:self.title];
    [self.descriptionLabel setText:self.description];


    float textHeight = [MLUtils calculateHeightOfTextFromWidth:self.description : descriptionLabel.font :descriptionLabel.frame.size.width :UILineBreakModeWordWrap];

    CGRect frame = descriptionLabel.frame;
    frame.size.height = textHeight;
    descriptionLabel.frame = frame;

    CGSize contentSize = descriptionScrollView.contentSize;
    contentSize.height = textHeight;
    descriptionScrollView.contentSize = contentSize;



- (void)viewDidUnload {
    self.cheatName = nil;
    self.description = nil;

}

【问题讨论】:

  • 你贴的代码上面的代码是什么?

标签: iphone xcode undeclared-identifier


【解决方案1】:

您缺少右括号:

- (void)viewDidLoad {
    [super viewDidLoad];

    [self.titleLabel setText:self.title];
    [self.descriptionLabel setText:self.description];


    float textHeight = [MLUtils calculateHeightOfTextFromWidth:self.description : descriptionLabel.font :descriptionLabel.frame.size.width :UILineBreakModeWordWrap];

    CGRect frame = descriptionLabel.frame;
    frame.size.height = textHeight;
    descriptionLabel.frame = frame;

    CGSize contentSize = descriptionScrollView.contentSize;
    contentSize.height = textHeight;
    descriptionScrollView.contentSize = contentSize;

} // <-- HERE

- (void)viewDidUnload {
    self.cheatName = nil;
    self.description = nil;

}

其次,我不确定这行是否有效:

float textHeight = [MLUtils calculateHeightOfTextFromWidth:self.description : descriptionLabel.font :descriptionLabel.frame.size.width :UILineBreakModeWordWrap];

我认为您必须添加参数名称,例如(虚构名称!):

float textHeight = [MLUtils calculateHeightOfTextFromWidth:self.description font: descriptionLabel.font width:descriptionLabel.frame.size.width whatever:UILineBreakModeWordWrap];

【讨论】:

  • 然后我收到一个错误: - (void)viewDidUnload { self.cheatName = nil; self.description = nil; } - (void)didReceiveMemoryWarning { // 如果没有超级视图,则释放视图。 [super didReceiveMemoryWarning]; // 释放所有未使用的缓存数据、图像等。 } - (void)dealloc { [titleLabel release]; [描述标签发布]; 【描述ScrollView发布】; [cheatName 释放]; [描述发布]; [超级释放]; } } @end
  • 错误在最后的两个括号中 - 它说我需要一个 "(" 在 "}" 标记之前如果我删除它,那么会有更多的错误没有意义项目(大约 35 个)
  • @nolimitsplayer:没有完整的代码很难说。我建议仔细阅读您的代码,折叠方法并查看折叠是否正确完成。验证左括号和右括号的数量是否相同等。
  • 我可以把文件上传给你吗?
  • 等一下,对于一个简单的应用程序 (WTF),它就像 65MB 我不知道该怎么办。所有的括号都在它们应该在的位置,等等。我该怎么办?我不想重新修复所有问题。
【解决方案2】:

通常这意味着您在该行上方的某处有错误。或者放错了 { }。

【讨论】:

    猜你喜欢
    • 2022-11-10
    • 2021-08-22
    • 2022-11-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-01-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多