在屏幕上,我有一个叫做namelabel和agelabel的标签。在agelabel之上设置namelabel。这两个标签的数据取自带有sqlite的Lita。我想做的是,如果Lita中没有名字数据,我想把agelabel移到名字标签的位置。我已经写了下面的代码,但是它不能工作。//Lita的数据表名称为table。
if(table.age == nil) {
UILabel *agelabel = [[UILabel alloc] initWithFrame: CGRectMake(20,350,100,30)];
agelabel.text = table.age;
[self.view addSubview:agelabel];
} else {
UILabel *namelabel = [[UILabel alloc] initWithFrame: CGRectMake(20,350,100,30)];
namelabel.text = table.name;
[self.view addSubview:namelabel];
UILabel *agelabel = [[UILabel alloc] initWithFrame: CGRectMake(20,370,100,30)];
agelabel.text = table.age;
[self.view addSubview:agelabel];
}请帮我解决这个问题。非常感谢。
发布于 2013-11-19 08:50:28
我用下面的代码解决了这个问题:
if ([table.age length] == 0){}https://stackoverflow.com/questions/19997695
复制相似问题