2013-04-10 105 views

回答

0

您应该将静态单元格绑定到您的UITableViewController中的网点,并将配置文件同步方法设置为- viewWillAppear方法。

当用户更改国家/地区列表中的国家/地区时,配置文件会更新。之后,当用户移回带有静态内容的UITableViewController实例时,配置文件数据将自动更新。

0

您可以在CityTableView中定义一个委托,然后在此委托中定义一个方法。

您应该在CountryTableView中实现此方法。

然后你可能会得到你想要的。

我只给你一个想法。你应该自己找到细节。

0

MasterViewController.h

#import "DetailViewController.h" 

@interface MasterViewController : UITableViewController <DetailProtocol> // Note this. 

@property (strong, nonatomic) DetailViewController *detailViewController; 
@property (strong, nonatomic, readwrite) NSString *selectedCountry; 

@end 

MasterViewController.m

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    if (!self.detailViewController) { 
     self.detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; 
    } 
    self.detailViewController.delegate = self; // THIS IS IMPORTANT... 
    [self.navigationController pushViewController:self.detailViewController animated:YES]; 
} 

// Note this -- It's a delegate method implementation 
- (void)setCountry:(NSString *)country 
{ 
    self.selectedCountry = country; 
} 

DetailViewController.h

@protocol DetailProtocol <NSObject> 
-(void)setCountry:(NSString *)country; 
@end 

@interface DetailViewController : UIViewController 

@property (strong, nonatomic) IBOutlet UITableView *tableView; 
@property (unsafe_unretained) id <DetailProtocol> delegate; // Note this 

@end 

DetailViewController.m

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; 
    [self.delegate setCountry:[countries objectAtIndex:indexPath.row]]; // Note this 
    [self.navigationController popViewControllerAnimated:YES]; 
} 
相关问题