2014-07-24 30 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];