我正在开发一个应用程序,可以存储联系人。在表格视图中,我的名字显示出来,但希望也有名字和右侧的日期。名字被保存为拳头名称,日期字段保存为日期。任何人都可以运行我如何做到这一点?有名字,第一个和日期显示在桌面上
感谢
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [[self.fetchedResultsController sections]count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
id <NSFetchedResultsSectionInfo> secInfo = [[self.fetchedResultsController sections] objectAtIndex:section];
return [secInfo numberOfObjects];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
Contacts *contacts = [self.fetchedResultsController objectAtIndexPath:indexPath];
cell.textLabel.text = contacts.name;
return cell;
}
-(NSString *) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return [[[self.fetchedResultsController sections]objectAtIndex:section]name];
}
怎么回事? – 2013-05-11 02:02:56
什么问题是我不知道如何做到这一点。我试图在名称文本字段后添加“cell.textLabel.text = contacts.firstname”,但只是名字而不是两个。 – Scubadivingfool 2013-05-11 02:06:38
你在使用StoryBoards吗? – 2013-05-11 02:08:16