2013-12-18 26 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(搜索 「創建導航界面」)