1

我想要四个 ScrollViews,比如iCarousel的 CoverFlow 在 View 中以编程方式。我的代码是

    // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
    - (void)viewDidLoad
    {
        [super viewDidLoad];

        //set up data
        wrap = YES;
        self.items = [NSMutableArray array];
        for (int i = 0; i < NUMBER_OF_ITEMS; i++)
        {
            [items addObject:[NSNumber numberWithInt:i]];
        }

        carousel1 = [[carousel1 alloc] init];
carousel2 = [[carousel2 alloc] init];
carousel3 = [[carousel3 alloc] init];
carousel4 = [[carousel4 alloc] init];

        carousel1.frame = CGRectMake(0, 0, 320, 120);
        carousel2.frame = CGRectMake(0, 120, 320, 120);
carousel3.frame = CGRectMake(0, 240, 320, 120);
carousel4.frame = CGRectMake(0, 360, 320, 120);

        carousel1.delegate = self;
carousel2.delegate = self;
carousel3.delegate = self;
carousel4.delegate = self;

        carousel1.dataSource = self;
carousel2.dataSource = self;
carousel3.dataSource = self;
carousel4.dataSource = self;
        [self.view addSubview:carousel1];
[self.view addSubview:carousel2];
[self.view addSubview:carousel3];
[self.view addSubview:carousel4];

        //configure carousel
        carousel1.type = iCarouselTypeCoverFlow2;
carousel2.type = iCarouselTypeCoverFlow2;
carousel3.type = iCarouselTypeCoverFlow2;
carousel4.type = iCarouselTypeCoverFlow2;

    }

但在没有将轮播视图放在视图上的情况下失败并出现四个警告。请帮助我克服这个问题。提前致谢。

4

1 回答 1

1

你不应该用 [[iCarousel alloc] init] 而不是 [[carousel1 alloc] init] 来初始化它们吗?

于 2011-10-01T14:49:52.333 回答