我想从数据库加载数据到uipickerview。 这是我的代码如何在iphone中从数据库加载uipickerview值?
if (sqlite3_prepare_v2(UsersDB, query_stmt, -1, &statement, NULL) == SQLITE_OK)
{
int i=0;
while (sqlite3_step(statement) == SQLITE_ROW)
{
NSLog(@"select");
self.coun=[[NSString alloc] initWithUTF8String:(char *)sqlite3_column_text(statement, 0)];
NSLog(@"Coun = %@",coun);
self.animals=[coun componentsSeparatedByString:@":"];
NSLog(@"String value=%@",self.animals);
}
sqlite3_finalize(statement);
} else
{
NSLog(@"not select");
}
和按钮操作的代码是
- (IBAction)selectAnItem:(UIControl *)sender {
//Display the ActionSheetPicker
[ActionSheetPicker displayActionPickerWithView:sender data:self.animals selectedIndex:self.selectedIndex target:self action:@selector(itemWasSelected::) title:@"Select Country"];
}
但运行负荷只有最后一个值。并非所有值都在UIpickerview中加载。如何使用此代码加载数据库中的所有值。任何人都可以帮助我。提前致谢。
笏是乌拉圭回合的动物对象,则达Array.And你的数据库的价值明杆怎么会? –
动物是NSArray。 coun是NSString – akk
是否所有的动物值都存储为单个字符串在你的DB.Like动物1:anilmal2:animal3 –