我的视图上有两个容器视图,试图模仿左侧的拆分视图控制器 tableview 和右侧的详细视图。在 master 上使用didselect
row 时tableview
,详细视图应显示一些详细信息
问题是当我将数据传递给详细视图控制器实例时,它总是返回 null。
在主人:
@property (nonatomic,strong) LogDetailViewController *wods;
UIStoryboard* sb = [UIStoryboard storyboardWithName:@"MainStoryboard"
bundle:nil];
self.wods= [sb instantiateViewControllerWithIdentifier:@"LogDetailViewController"];
//also tried self.wods= [[LogDetailViewController alloc] init];
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//one of the if else method rest of it was too long
else if ([indexPath section]==1){
GIRLS *girls =[self.girlsList objectAtIndex:indexPath.row];
self.wods.girls = girls;
self.wods.section=1;
[[NSNotificationCenter defaultCenter] postNotificationName:@"refreshLOGDetails" object:nil];
}
}
详细地:
@property int section;
@property (nonatomic, strong) GIRLS *girls;
//refresh notification
extern NSString * const NOTIF_refreshLOGDetails;
@synthesize section;
@synthesize girls;
- (void)refreshLOGDetails:(NSNotification *)notif
{
NSLog(@"Notification refreshLOGDetails works");
[self configureView];
}
- (void)configureView
{
//also tried self.girls and self.section
NSLog(@"Section is %i",section);
NSLog(@"configure view object %@",girls);
}
输出:
Notification refreshLOGDetails works
Section is 0
configure view object (null)
我做错了什么?为什么我得到空值?