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

确保您的视图启用了用户交互以注册触摸。这可以在您的视图控制器中设置,因此:

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