0

我对 iOS 有点陌生。我知道一个void methodie

-(void) pressed {

}

可以这样调用:

[self pressed];

viewDidAppear 可以这样称呼:

[self viewDidAppear:YES];

我正在徘徊如何在下面的这种方法中做到这一点,或者如何重新调用它:

- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{

    return [images count];
}
4

2 回答 2

1

你不应该调用-(void)viewDidAppear:(BOOL)animated,它是生命周期的一部分,UIViewController它会被自动调用。至于另一个:

- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
    return [images count];
}

我从未使用过iCarousel,但它似乎是来自数据源的方法,因此也不应该直接调用。

于 2012-07-09T06:29:03.593 回答
0

那可能是我的数据源方法......它是从控制器调用的。

//And it may be called in the controller as below where delegate is object of some class
    iCarousel *iCarouselObj;
    if(delegate && [delegate respondsToSelector:@selector(numberOfItemsInCarousel:)])
        int items = [delegate numberOfItemsInCarousel:iCarouselObj];

//The below code is just to tell you how to call a method with arguments
iCarousel *iCarouselObj;
int items = [self numberOfItemsInCarousel:iCarouselObj];
于 2012-07-09T06:47:26.423 回答