0

オブジェクトを手動で作成し (File -> New -> NewClass -> UITableViewCell)、.xib を追加しました。作成されたセルにはいくつかのラベルがあります。画像を参照してください作成されたセル

その後、このオブジェクトを他のクラスで使用します

myCell * showHere;
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"myCell" owner:self options:nil];
showHere = [nib objectAtIndex:0];

このセルにUIlabelのgestureRecognizerを追加するにはどうすればよいですか?

私はこれを試しました:

UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] 
                                           initWithTarget:self 
                                           action:@selector(handleLongPress:)];
longPress.minimumPressDuration = 1.0;
[showHere.monday addGestureRecognizer:longPress];

この

    -(void)handleLongPress:(UILongPressGestureRecognizer*)recognizer {
NSLog(@"label has pressed");

}

単一のラベルを押してアクションをキャッチする必要があります。出来ますか?私の英語でごめんなさい。

4

1 に答える 1

1

YourLabel.userinteractionEnabled = YES後に追加する

UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; longPress.minimumPressDuration = 1.0;

ラベルへのタッチを有効にするには

幸運を

于 2012-07-30T12:43:08.570 に答える