无法从UICollectionReusableView中删除

时间:2013-12-18 16:30:52

标签: uicollectionview segue uicollectionreusableview

我有UICollectionView和Header.I有textfield和image.I确实尝试push segue工作正常。但我需要调用segue! 任何帮助将不胜感激

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

1 个答案:

答案 0 :(得分: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(搜索"创建导航界面")