- (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict
{
if( [elementName isEqualToString:@"PublicBusinessName"])
{
boolListofareasdata=YES;
}
else if( [elementName isEqualToString:@"ProfessionName"])
{
boolListofareasdata1=YES;
}
else if( [elementName isEqualToString:@"PublicContactEmail"])
{
boolListofareasdata2=YES;
}
else if( [elementName isEqualToString:@"PublicBusinessURL"])
{
boolListofareasdata3=YES;
}
else if( [elementName isEqualToString:@"BrandLogoName"])
{
boolListofareasdata4=YES;
}
}
- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string
{
if (boolListofareasdata)
{
[arrareasdata addObject:string];
NSLog(@"NAME...............%@",arrareasdata);
}
else if (boolListofareasdata1)
{
[arrareasdata1 addObject:string];
NSLog(@"DESIGN..............%@",arrareasdata1);
}
else if (boolListofareasdata2)
{
[arrareasdata2 addObject:string];
NSLog(@"DESIGN..............%@",arrareasdata1);
}
else if (boolListofareasdata3)
{
[arrareasdata3 addObject:string];
NSLog(@"WEB....................%@",arrareasdata3);
}
else if (boolListofareasdata4)
{
[arrareasdata4 addObject:str];
NSLog(@"WEB....................%@",arrareasdata4);
}
}
-(void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI: (NSString *)namespaceURI qualifiedName:(NSString *)qName
{
if ([elementName isEqualToString:@"PublicBusinessName"])
{
boolListofareasdata=NO;
}
else if ([elementName isEqualToString:@"ProfessionName"])
{
boolListofareasdata1=NO;
}
else if( [elementName isEqualToString:@"PublicContactEmail"])
{
boolListofareasdata2=NO;
}
else if ([elementName isEqualToString:@"PublicBusinessURL"])
{
boolListofareasdata3=NO;
}
else if ([elementName isEqualToString:@"BrandLogoName"])
{
boolListofareasdata4=NO;
}
}
- (void)parserDidEndDocument:(NSXMLParser *)parser{
[tableView reloadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [arrareasdata3 count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CustomCell";
CustomCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
for (id currentObject in topLevelObjects)
{
if ([currentObject isKindOfClass:[UITableViewCell class]])
{
cell = (CustomCell *) currentObject;
break;
}
}
}
NSLog(@"TABLE VIEW CONTROLLER........................");
cell.nameLabel.text = [arrareasdata objectAtIndex:indexPath.row];
cell.designLabel.text = [arrareasdata1 objectAtIndex:indexPath.row];
cell.emailLabel.text = [arrareasdata2 objectAtIndex:indexPath.row];
cell.webLabel.text = [arrareasdata3 objectAtIndex:indexPath.row];
return cell;
}
问问题
359 次
1 回答
0
在 uitableviewcell 中添加空值,如下所示:
NSString *strName = [arrareasdata objectAtIndex:indexPath.row];
if((strName.length > 0)
{
cell.nameLabel.text = strName;
}
else
{
cell.nameLabel.text = @"";
}
//same logic for designLabel,emailLabel,webLabel in which u will fill your data
于 2012-08-13T11:28:06.390 回答