Я пытаюсь создать приложение, подобное контактам, для iphone, в котором имя контакта отображается вверху (для этого я пишу код в viewForHeaderInSection), а затем подробности следует в сгруппированном разделе.Проблема в том, что я получаю значения из базы данных, и если имя пустое, оно отображается в таблице.Я хочу удалить нулевые значения и отобразить поля, в которых есть значения.Имена сохраняются в массиве.Я пытаюсь получить следующие поля из базы данных для отображения в таблице.
NSMutableArray *nameSectionDetails=[[NSMutableArray alloc]initWithObjects:[eachContact objectAtIndex:0], [eachContact objectAtIndex:1], [eachContact objectAtIndex:2],[eachContact objectAtIndex:3],[eachContact objectAtIndex:4],[eachContact objectAtIndex:19],nil];
NSMutableDictionary * nameSection = [[NSMutableDictionary alloc] initWithObjectsAndKeys: nameSectionDetails, @ "name", nil];self.labelSection = nameSection;
eachContact содержит все сведения о конкретном контакте.
Здесь я пытаюсь отобразить
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
if(section == 0) {
// create the parent view that will hold 1 or more buttons
UIView* buttonView = [[[UIView alloc] initWithFrame:CGRectMake(10.0, 0.0, 300.0, 100.0)]autorelease];
UILabel *updateDeletedLabel = [[[UILabel alloc] initWithFrame:CGRectMake(10.0, 0.0, 300.0, 60.0)] autorelease];
/*updateDeletedLabel.text = [NSString stringWithFormat:@"%@\n%@ %@\n%@\n%@",[eachContact objectAtIndex:1],[eachContact objectAtIndex:3],[eachContact objectAtIndex:2],[eachContact objectAtIndex:3],[eachContact objectAtIndex:4],[eachContact objectAtIndex:19]];*/
/*for(int i=1;i<[[labelSection objectForKey:@"name"]count];i++)
{
if([[[labelSection objectForKey:@"name"]objectAtIndex:i] isEqualToString:@"(null)"])
[[labelSection objectForKey:@"name"]removeObjectAtIndex:i];
//i+=i*i;
}*/
updateDeletedLabel.text=[NSString stringWithFormat:@"%@ %@ %@\n%@\n%@\n%@",[[labelSection objectForKey:@"name"]objectAtIndex:1],[[labelSection objectForKey:@"name"]objectAtIndex:3],[[labelSection objectForKey:@"name"]objectAtIndex:5],[[labelSection objectForKey:@"name"]objectAtIndex:7],[[labelSection objectForKey:@"name"]objectAtIndex:9],[[labelSection objectForKey:@"name"]objectAtIndex:11]];
updateDeletedLabel.font = [UIFont systemFontOfSize:12];
updateDeletedLabel.numberOfLines = 0;
updateDeletedLabel.lineBreakMode = UILineBreakModeWordWrap;
updateDeletedLabel.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0];
[updateDeletedLabel setTextAlignment: UITextAlignmentCenter];
// add the button to the parent view
[buttonView addSubview:updateDeletedLabel];
return buttonView;
}
return nil;
}
Может кто-нибудь, пожалуйста, помогите мне в этом отношении.Я новичок в изучении приложений для iphone, и если вы можете предложить какой-либо другой метод, я рад это знать.Спасибо !!!