0

UItextViewがスライドしているときにメソッドを呼び出し、そのタグを判別したいと思います。私はこのコードを使用していました:

-(IBAction)donecomment:(id)sender{

UISwipeGestureRecognizer *myLongPressRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(holdpress:)];
[textname addGestureRecognizer:myLongPressRecognizer];

textname.editable = NO;
textname.userInteractionEnabled = YES;

CGRect frame = textname.frame;
frame.size.height = textname.contentSize.height;
textname.frame = frame;

heightInteger = heightInteger + textname.contentSize.height + 6;

[textnameArray addObject:textname];

addComment.hidden = NO;
doneComment.hidden = YES;
cancelComment.hidden = YES;
}

-(void)holdpress:(id)sender{

UITextView *txtChoosen = (UITextView*) sender;

for (UITextView* txt in textnameArray) {
    if (txt.tag == txtChoosen.tag) {

        txt.layer.borderWidth = 5.0f;
        txt.layer.borderColor = [[UIColor whiteColor] CGColor];
    }else{

        txt.layer.borderWidth = 0.0f;
        txt.layer.borderColor = [[UIColor whiteColor] CGColor];
}}

...このエラーが発生します:理由:'-[PhotoViewController holdpress]:認識されないセレクターがインスタンス0x22c1a000に送信されました'

私はそれを使用してそれを解決できると思います:

- (void)rightSwipeHandle:(UISwipeGestureRecognizer*)gestureRecognizer

...しかし、htisを使用することは、送信者を削除することを意味します。私に何ができる?

4

2 に答える 2

1

エラーは、という名前のメソッドについて不平を言っていholdpressます。投稿したコードには、という名前のメソッドがありますholdpress:。違いに注意してください。メソッドにはコロンがありますが、エラーメソッドにはありません。

また、投稿したコードで、のセレクターを使用するようにジェスチャーレコグナイザーを設定しましたholdpress:。これは、実際に使用している方法と適切に一致します。それは正しいです。

エラーは約holdpressであり、ではないため、の代わりにセレクターholdpress:を使用しようとする他のコードが必要です。holdpressholdpress:

投稿されたコードはからPhotoViewControllerですか?

holdpress(ではなく)への呼び出しをコードで検索しますholdpress:

于 2013-01-22T18:22:24.770 に答える
0

最終的解決:

-(IBAction)donecomment:(id)sender{

UISwipeGestureRecognizer *myLongPressRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(leftSwipe:)];
 //[myLongPressRecognizer setDirection:(UISwipeGestureRecognizerDirectionUp)];
[textname addGestureRecognizer:myLongPressRecognizer];

textname.editable = NO;
textname.userInteractionEnabled = YES;

CGRect frame = textname.frame;
frame.size.height = textname.contentSize.height;
textname.frame = frame;

heightInteger = heightInteger + textname.contentSize.height + 6;

[textnameArray addObject:textname];

addComment.hidden = NO;
doneComment.hidden = YES;
cancelComment.hidden = YES;

}

- (void)leftSwipe:(UISwipeGestureRecognizer *)recognizer {

id sender;
UITextView *txtChoosen = (UITextView*) sender;

for (UITextView* txt in textnameArray) {
    if (txt.tag == txtChoosen.tag) {

        txt.layer.borderWidth = 5.0f;
        txt.layer.borderColor = [[UIColor whiteColor] CGColor];
    }else{

        txt.layer.borderWidth = 0.0f;
        txt.layer.borderColor = [[UIColor whiteColor] CGColor];
}}
于 2013-01-22T18:34:40.490 に答える