以下是我的代码...为Quiz App生成许多标签以显示答案
for (NSInteger i = 0, y = 50; i < 3 ; i++, y += 30) {
UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 50, 100, 25)];
_optoin1 = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, 2)]; _op1.text= _optoin1;
nameLabel.text =_optoin1;
[_myscrollView addSubview:nameLabel];
sqlite3_finalize(statement);
key++;
}
答案 0 :(得分:0)
key用于从db获取下一个columnvalue。它生成四个标签..
for (NSInteger i = 0, y = 50; i < 4 ; i++, y += 30)
{
UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, y, 100, 25)];
_optoin1 = [[NSString alloc] initWithUTF8String:(const char *) sqlite3_column_text(statement, key)];
nameLabel.tag = labl_id;
nameLabel.text =_optoin1;
[_myscrollView addSubview:nameLabel];
//sqlite3_finalize(statement);
key++;
labl_id++;
}