我有2個標籤。關於iCarousel和標籤iOS
名爲「標籤」的第一個標籤放置在傳送帶內的每個視圖內。標籤的字符串/文本是視圖的索引。
label.text = [[items1 objectAtIndex:index] stringValue];
我還有一個名爲「outsideLabel」的第二個標籤(傳送帶之外)。 我想讓outsideLabel的字符串/文本成爲視圖的索引(總是視圖在旋轉木馬前面)。
outsideLabel.text = [[items1 objectAtIndex:index] stringValue];
不知怎的,我做錯了,不知道我應如何以顯示outsideLabel的字符串/文本正確的數量(總是在前面是視圖)的代碼這一點。代碼有點顯示正確的數字,但在旋轉木馬中向後滾動時會變得混亂。轉盤類型是timeMachine。
我當前的代碼:
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view
{
//create new view if no view is available for recycling
if (view == nil)
{
view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200.0f, 200.0f)];
view.contentMode = UIViewContentModeCenter;
label = [[UILabel alloc] initWithFrame:view.bounds];
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor whiteColor];
if (carousel == carousel1)
{
CGRect test = CGRectMake(10, 10, 20, 20);
self.label.frame = test;
}
else {
CGRect test = CGRectMake(50, 40, 40, 40);
self.label.frame = test;
}
[view addSubview:label];
}
else
{
label = [[view subviews] lastObject];
}
if (carousel == carousel1)
{
//items in this array are numbers
outsideLabel.text = [[items1 objectAtIndex:index] stringValue];
label.text = [[items1 objectAtIndex:index] stringValue];
((UIImageView *)view).image = [UIImage imageNamed:[view1background objectAtIndex:index]];
}
else
{
//not relevant....
}
return view;
}
你試過iCarousel的委託方法 - - (void)carouselCurrentItemIndexDidChange:(iCarousel *)carousel?嘗試在這裏設置值..希望這可能會幫助你 – Nayan