2011-10-01 62 views
1

我希望以编程方式在视图中使用iCarousel的CoverFlow这样的四个ScrollViews。我的代码是如何以编程方式将iCarousel放在视图中?

// 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; 

    } 

但失败,出现四个警告,将视频轮播视图放在外面。请帮我解决这个问题。提前致谢。

回答

1

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

+1

再次感谢你 – Lion

相关问题