1

私は次のviewDidLoad()メソッドを実装しました:

- (void)viewDidLoad {
    [super viewDidLoad];

    // loading images into the queue
    loadImagesOperationQueue = [[NSOperationQueue alloc] init];
    AFOpenFlowView *openFlow = self.view;
    theControl = [[UIControl alloc] initWithFrame:self.view.frame];
    NSString *imageName;
    btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(10, 10, 40, 40);
    [btn addTarget:self action:@selector(testMethode) forControlEvents:UIControlEventTouchUpInside];
    [btn setTitle:@"<<" forState:UIControlStateNormal];
    [btn setHidden:YES];
    [theControl addSubview:btn];

    for (int i=0; i < 10; i++) {
        imageName = [[NSString alloc] initWithFormat:@"cover_%d.jpg", i];
        imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
        UIImage *aktuellesImage = imageView.image;
        UIImage *scaledImage = [aktuellesImage scaleToSize:CGSizeMake(100.0f, 100.0f)];
        [openFlow setImage:scaledImage forIndex:i];
//      [(AFOpenFlowView *)self.view setImage:scaledImage forIndex:i];

        [imageName release];
        [aktuellesImage release];       
    }
    [theControl addSubview:openFlow];
    [theControl setUserInteractionEnabled:YES];

    [(AFOpenFlowView *)self.view setNumberOfImages:10];
}

そして、次の touchesEnded() メソッド:

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    [btn setHidden:NO];
}

しかし、 touchesEnded が機能せず、画像に触れてもボタンが表示されません。問題は何か知っていますか?

こんにちはマルコ

4

1 に答える 1

0

タッチを登録するには、ビューでユーザー インタラクションが有効になっていることを確認してください。これは、View Controller で次のように設定できます。

self.view.userInteractionEnabled = YES;
于 2011-05-28T19:24:06.967 に答える