程序不会跳转到Delegate-Method

时间:2010-11-08 07:22:51

标签: debugging delegates ios4

早安社区,

我有一个问题,因为我已经用Delegate方法实现了一个CoverFlowViewController.m,但调试器从未跳过这个方法,有人知道为什么吗? 这是代码:

- (void)viewDidLoad {
    [super viewDidLoad];
    UIButton *weiter = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    weiter.frame = CGRectMake(100, 400, 120, 40);
    [weiter addTarget:self action:@selector(goToChart) forControlEvents:UIControlEventTouchUpInside];
    NSString *ansicht = @"Weiter";
    [weiter setTitle:ansicht forState:UIControlStateNormal];
    [self.view addSubview:weiter];
    // loading images into the queue
    loadImagesOperationQueue = [[NSOperationQueue alloc] init];
    NSString *imageName;
    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)];
        [(AFOpenFlowView *)self.view setImage:scaledImage forIndex:i];
    }
    [(AFOpenFlowView *)self.view setNumberOfImages:10];

}

- (void)openFlowView:(AFOpenFlowView *)openFlowView selectionDidChange:(int)index{
    NSLog(@"%d is selected",index);
}

有谁知道调试器(= Programm)从未跳转到selectionDidChange()方法的原因?

三天后我没有解决方案,希望有人可以帮助我?

问候并先谢谢你 马可

2 个答案:

答案 0 :(得分:1)

你确定你将viewDelegate连接到你的viewController吗? 请在viewDidLoad方法的末尾添加NSLog(@"Delegate: %@", ((AFOpenFlowView*)self.view).viewDelegate);以查看它是否已连接。

答案 1 :(得分:0)

添加

((AFOpenFlowView *)self.view).viewDelegate = self;在init或viewDidLoad方法