2010-11-08 36 views
0

早安社區,計劃在代表法不跳

我有一個問題,因爲我已經實現與委託方法的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()方法?

我三天沒有解決方法,希望有人能幫助我?

問候,並感謝您事先 馬爾科

回答

1

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

+0

嗨fluchtpunkt,我已經添加了你的線,並且控制檯說:2010-11-08 13:44:52.478 CoverFlow [1504:207]委託人:(null) 我應該做些什麼確實,它有效嗎? – Marco 2010-11-08 12:34:21

0

Add

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