如何将数据从视图控制器传递到UICollectionReusableView

时间:2018-02-07 07:26:53

标签: ios objective-c iphone uiviewcontroller

我有2个viewcontrollers(A和B)。当我点击VC A中的选定记录时,它将重定向到VC B.在我的VC B中,我有UICollectionReusableView显示标题以获取详细信息。

我是否知道如何将数据从VC A传递到VC B UICollectionReusableView?随附我的代码: -

VC A(我能在这里获得NSLog的值)

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    Merchant_TableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath];

    //Link to Shop page
    MerchantDetail_ViewController *MerchantDetail_ViewControl = [[MerchantDetail_ViewController alloc] init];

    MerchantDetail_HeadView *MerchantDetail_Head = [[MerchantDetail_HeadView alloc] init];

    MerchantDetail_Head.strName = cell.nameLabel.text;
    NSLog(@"strname - %@",MerchantDetail_Head.strName);


    [self.navigationController pushViewController:MerchantDetail_ViewControl animated:YES];

}

在VC B UICollectionReusableView .h文件中

@interface MerchantDetail_HeadView : UICollectionReusableView

@property (nonatomic, retain) IBOutlet NSString *strName;
@property (nonatomic, retain) IBOutlet NSString *strImage;

在VC B UICollectionReusableView .m文件中(此处NSLog将获取空值)

- (void)awakeFromNib {
    [super awakeFromNib];

    self.headImageButton.clipsToBounds = YES;
    self.headImageButton.layer.cornerRadius = 30;

    self.nickNameLabel.text = strName;
    NSLog(@"Head View - %@",strName);
}

有什么想法吗?请帮助thx。

0 个答案:

没有答案