我将 iCarousel 应用程序与单 View 应用程序集成在一起。但是当我添加标签栏 Controller 并将此 iCarousel 代码放在一个标签栏项目 View Controller 中时。但它不起作用(显示项目但不滚动)。这里有什么问题。
我创建了 iCarousel,如下所示:
iCarousel *categorySubView = [[iCarousel alloc]initWithFrame:CGRectMake(0,200, 300, 125)];
categorySubView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
categorySubView.delegate = self;
categorySubView.dataSource = self;
categorySubView.type=iCarouselTypeRotary;
[self.view addSubview:categorySubView];
我正在使用以下委托(delegate)和数据源方法:
-(NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
return 5;
}
- (UIView *) carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view{
UIView *sampleView=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 250, 300)];
sampleView.backgroundColor=[UIColor whiteColor];
UILabel *labelis=[[UILabel alloc]initWithFrame:CGRectMake(10, 10, 100, 20)];
labelis.backgroundColor=[UIColor clearColor];
labelis.text=@"8Apr-14Apr";
[sampleView addsubView:labelis];
return sampleView;
}
请给我建议。
提前致谢
最佳答案
我注意到您的轮播 View 比其中的项目大小要小得多(它只有 125 点高)。
iCarousel 可以在其边界之外绘制,但它无法检测到其边界之外的触摸事件,因此这可能是您无法滚动的原因。
调试它的一个好方法是设置 carousel.clipsToBounds = YES,这样它绘制的内容将匹配可触摸的内容。另一种选择是设置 carousel.backgroundColor 以便您可以在屏幕上看到它的哪一部分是可触摸的。
要检查的另一件事是,您放置轮播的 View 已将 userInteractionEnabled 设置为 YES。
关于ios6 - iCarousel 与 iOS 6.1 中具有标签栏 Controller 的应用程序集成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15895605/