use*_*541 3 objective-c ios icarousel
我正在尝试使用iCarousel库在我的应用程序中实现轮播类型选择器,但是当我加载应该显示轮播的视图时,什么都没有出现.
这是相关的代码:
iCarousel委托方法:
- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel {
return 65;
}
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view {
// Create a number label representing a numeric WPM option
UILabel *numberLabel = nil;
// Create new view if no view is available for recycling
if (!view) {
view = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 220, 60)];
numberLabel = [[UILabel alloc] initWithFrame:view.bounds];
numberLabel.backgroundColor = [UIColor clearColor];
numberLabel.textColor = [UIColor whiteColor];
numberLabel.textAlignment = NSTextAlignmentCenter;
numberLabel.tag = 1;
[view addSubview:numberLabel];
}
else {
numberLabel = (UILabel *)[view viewWithTag:1];
}
// Calculate the number's value depending on the index value being retrieved
int number = 200 + (index * 20);
numberLabel.text = [@(number) stringValue];
return view;
}
Run Code Online (Sandbox Code Playgroud)
并在viewDidLoad::
self.carousel = [[iCarousel alloc] initWithFrame:CGRectMake(120, 35, 150, 50)];
self.carousel.type = iCarouselTypeLinear;
[self.view addSubview:self.carousel];
Run Code Online (Sandbox Code Playgroud)
究竟我错过了什么搞砸了?
我没有使用过iCarousel,但也许你没有设置委托和/或dataSource?
self.carousel.delegate = self;
self.carousel.dataSource = self;
Run Code Online (Sandbox Code Playgroud)
从您显示的代码看起来并不像您这样做.
| 归档时间: |
|
| 查看次数: |
1088 次 |
| 最近记录: |