我一直在网上搜索很长一段时间试图解决这个问题。我想创建一个社交网络应用程序,允许我有自定义表格单元格从sqlite数据库中提取数据。我希望将用户个人资料图片添加到表格单元格的左侧,并将他们的用户名添加到单元格的右侧。我知道我需要一个从sqlite数据库中提取BLOB图像的图像视图,我知道我需要一个标签来显示用户名。我也想让它像facebook和twitter一样实时更新。我已经创建了sqlite数据库并设计了用户界面。我只是不知道从哪里去。任何帮助将不胜感激!!
答案 0 :(得分:0)
UITableView
。UITableView
UITableView
的内容时,您需要再次触发查询。从您的SQLite获取数据。并且,重新加载您的tableview。答案 1 :(得分:0)
我使用Core Data执行此操作,here是一个很好的起点。 您可以从sqlite fetch records将其更改为对象,以便操作它们。
请参阅here以了解如何添加tableView。
关键方法是tableView:cellForRowAtIndexPath:
。
您将自定义您的单元格。
知道UITableViewDataSource
和UITableViewDelegate
对于使用UITableView非常重要。
您可以创建UITableViewCell的子类,可能是MyTableViewCell,以显示用户的头像和名称。 或者您可以使用默认的UITableViewCell,因为它有一个imageView和一个标签,可以满足您的需求。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"TableViewCellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (nil == cell) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier] autorelease];
}
// Do something here
cell.imageView.image = user.avatar;
cell.detailTextLabel.text = user.name;
return cell;
}
答案 2 :(得分:0)
您可以创建一个方法,该方法可能包含获取数据和重新加载表的代码。然后创建NSTime触发器并调用方法