0

プルしてリフレッシュする「機能」(CollectionView をリフレッシュする) の次のコードがあります。

UIRefreshControl *refreshControl = UIRefreshControl.alloc.init;
[refreshControl addTarget:self action:@selector(startRefresh:)
         forControlEvents:UIControlEventValueChanged];
[self.collectionView addSubview:refreshControl];

ただし、これによりアプリがクラッシュし、次のエラー メッセージが表示されます。

[CollectionViewController startRefresh:]: unrecognized selector sent to instance 0x7543610
2013-03-24 12:20:10.049 

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CollectionViewController startRefresh:]: unrecognized selector sent to instance 0x7543610'

ここで何が欠けていますか?ありがとう!

4

1 に答える 1

1

startRefresh:メソッドが引数を取ることを確認してください。それが in のコロンの@selector(startRefresh:)意味です。表示されるエラーは、メソッドを見つけて実行できないことを意味します。

セレクターとは何か、およびターゲット アクション パターンを実装する正しい方法を知るには、こちらこちらのドキュメントを参照することをお勧めします。

于 2013-03-24T11:47:11.523 に答える