我想從數據庫加載數據到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 –