【问题标题】:Can't segue from UICollectionReusableView无法从 UICollectionReusableView 中分离
【发布时间】:2013-12-18 16:30:51
【问题描述】:

我有 UICollectionView 和 Header。我有文本字段和图像。我确实尝试推送 segue 工作正常。但我需要调用 segue! 任何帮助将不胜感激

头文件.h

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


@end

标题.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

【问题讨论】:

    标签: uicollectionview segue uicollectionreusableview


    【解决方案1】:

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

    - (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(搜索“创建导航界面”)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-16
      • 1970-01-01
      • 2013-08-02
      • 2016-07-23
      • 2021-05-15
      • 2013-11-29
      • 2021-06-25
      • 1970-01-01
      相关资源
      最近更新 更多