0

私は UICollectionView と Header.I を持っています。私は textfield と image.I を持っています。どんな助けでも感謝します

Header.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
4

1 に答える 1

0

私はあなたと同じ問題を抱えていました。空のプロジェクトで「collectionHeaderViewでセグエを実行」を完全に実行できるため、実際には非常に注意が必要です(試しました)。この問題の鍵は、ナビゲーション コントローラーの 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. モーダルとして表示される UIViewController に UINavigationController を追加する方法
  2. https://developer.apple.com/Library/ios/documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/NavigationControllers.html (「ナビゲーション インターフェイスの作成」を検索)
于 2014-08-31T07:09:10.287 に答える