2013-12-18 30 views
0

我有UICollectionView和Header.I有textfield和image.I确实尝试推塞格工作正常。但我需要调用塞格! 任何帮助会感激不能继续从UICollectionReusableView

Header.h

@interface HeaderRV : UICollectionReusableView 
@property (weak, nonatomic) IBOutlet UITextField *searchField; 
@property (weak, nonatomic) IBOutlet UILabel *titleLabel; 
- (IBAction)backButton:(id)sender; 


@end 

Header.m

@implementation HeaderRV 

- (id)initWithFrame:(CGRect)frame 
{ 
self = [super initWithFrame:frame]; 
if (self) { 
    // Initialization code 
} 
return self; 
} 
- (IBAction)backButton:(id)sender { 

if ([self.searchField isEditing]) { 
    [self.searchField resignFirstResponder]; 
} 
else{ 
    //segue need to be here 
} 

} 

@end 

回答

0

我有同样的问题,因为你做的。这实际上非常棘手,因为你可以在一个空的项目中完成“在collectionHeaderView中执行segue”(我试过)。我发现这个问题的关键是你的RootVC的导航控制器不是应用程序的初始VC
您可以通过在.m文件中添加以下几行来解决此问题,该文件显示了导航控制器的rootVC。

- (IBAction)next:(id)sender { 
[theRootVCinNavigationController] *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"[your identifier]"]; 
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:[theRootVCinNavigationController]]; 
[self presentViewController:navigationController animated:YES completion:nil]; 
} 

参考文献:

  1. How to add an UINavigationController to an UIViewController presented as Modal
  2. https://developer.apple.com/Library/ios/documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/NavigationControllers.html(搜索 “创建导航界面”)