Cocoa touch 从课外呼叫pushViewController?

Cocoa touch 从课外呼叫pushViewController?,cocoa-touch,ios7,Cocoa Touch,Ios7,我是iOS 7的新手。我正在努力调用pushViewController 我有MyCollectionViewController类,它是UINavigationController和CollectionViewCell类的根控制器,用于自定义采集单元格 在这种情况下,我可以在MyCollectionViewController中使用pushViewController: -(void)collectionView:(UICollectionView *)collectionView didSe

我是iOS 7的新手。我正在努力调用
pushViewController

我有
MyCollectionViewController
类,它是
UINavigationController
CollectionViewCell
类的根控制器,用于自定义采集单元格

在这种情况下,我可以在
MyCollectionViewController
中使用
pushViewController

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {

NSDictionary *product = self.products[indexPath.row];

TXDetailProductController *detailView = [[TXDetailProductController alloc] init];
detailView.product = product;

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

}

但是我想从
CollectionViewCell
类调用
pushViewController:detailView
,该类包含在
MyCollectionViewController

中。您可以轻松创建委托方法并将其定义到类中,您可以轻松创建委托方法并将其定义到您拥有的类中didSelectItemAtIndexPath,并从CollectionViewCell类调用委托方法

@protocol CollectionViewDelegate <NSObject>
-(void)pushMethod;

@end
@interface CollectionViewController : UIViewController
{
}
@property(nonatomic,retain)id<CollectionViewDelegate>delegate;

并且可以从CollectionViewCell类轻松调用此方法。

好的,有趣的是,您能否向我展示一个如何从CollectionViewCell调用pushMethod的代码片段。我已经尝试过TXCollectionViewController*cv=[[TXCollectionViewController alloc]init];与cv.pushMethod相比;但是没有成功!在集合视图单元类中,需要通过delegate.pushMethod调用并将委托给self
@protocol CollectionViewDelegate <NSObject>
-(void)pushMethod;

@end
@interface CollectionViewController : UIViewController
{
}
@property(nonatomic,retain)id<CollectionViewDelegate>delegate;