我有UICollectionView和Header.I,我有textfield和image.I,我尝试过推送工作fine.But,我需要调用segue!任何帮助都将不胜感激。
Header.h
@interface HeaderRV : UICollectionReusableView
@property (weak, nonatomic) IBOutlet UITextField *searchField;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
- (IBAction)backButton:(id)sender;
@endHeader.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发布于 2014-08-31 07:09:10
我和你有同样的问题。这实际上相当棘手,因为您可以在一个空项目中完美地完成“在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];
}参考文献:
https://stackoverflow.com/questions/20663420
复制相似问题