2014-07-24 83 views
0

我有一个带有不同注释的地图,我从json和服务器获得了这些信息,我可以向地图显示我的信息状态,我也想在我的表中显示它,我的表实现是正确的,当我用这个阵,我可以显示所有这些信息,以我的表:iOS:显示信息到UITableView

recipes = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto", @"Full 
Breakfast", @"Hamburger", @"Ham and Egg Sandwich", nil]; 

,但我不知道如何来显示表“状态”:

newAnnotation = [[MyAnnotation alloc] init]; 
newAnnotation.subtitle = dictionary[@"company"]; 
newAnnotation.status = dictionary[@"status"]; 



- (void)viewDidLoad 
{ 
[super viewDidLoad]; 

// recipes = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto", @"Full 
Breakfast", @"Hamburger", @"Ham and Egg Sandwich", nil]; 

_mapView.delegate = self; 

[ApiManager fetchCoordinates:^(id result) { 


    newAnnotations = [NSMutableArray array]; 
    CLLocationCoordinate2D location; 
    NSArray *array=(NSArray*)result; 


    for (NSDictionary *dictionary in array) 
    { 

     // create the annotation 
     MyAnnotation *newAnnotation; 


     newAnnotation = [[MyAnnotation alloc] init]; 
     newAnnotation.subtitle = dictionary[@"company"]; 
     newAnnotation.status = dictionary[@"status"]; 



     [newAnnotations addObject:newAnnotation]; 
    } 

    [self.mapView addAnnotations:newAnnotations]; 

} failure:^(NSError *error) { 

}]; 
} 

知道的任何代码在回答部分,提前致谢!

我的cellForRowAtIndexPath方法

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath 
*)indexPath 
{ 
static NSString *simpleTableIdentifier = @"Item"; 

UITableViewCell *cell = [tableView 
dequeueReusableCellWithIdentifier:simpleTableIdentifier]; 

if (cell == nil) { 
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault 
reuseIdentifier:simpleTableIdentifier]; 
} 


cell.textLabel.text = [recipes objectAtIndex:indexPath.row]; 
return cell; 
} 

更新:

我想补充这newAnnotation.status =辞典[@ “身份”];食谱或什么都NSArray的或...以显示它的表

+1

“食谱”和“状态”之间有什么关系? – Paulw11

+0

@ Paulw11没事,食谱是NSArray,状态位于这里newAnnotation.status = dictionary [@“status”];并且newAnnotation被添加到[newAnnotations addObject:newAnnotation];因为newAnnotations是NSMutableArray –

+1

如果没有关系,那么如何显示表中的状态?你想在自己的行中的地位?作为标题或页脚?显示在每一行? – Paulw11

回答

0

尝试做这样的事情在你的CellForRowAtIndexPathMethod做到这一点

MyAnnotation * newAnnotation = [newAnnotations objectAtIndex:indexpath.row]。

然后 只是用它作为

cell.textLabel.text = [NSString的stringWithFormat:@ “%@”,newAnnotaion.Status];