编辑:
我正在制作一个类似老虎机的应用程序,我iCarousel为插槽对象添加了.所以我有一个旋转的按钮iCarousel.在我的iCarousel视图中有两个插槽(Slot1和Slot2).以下是我iCarouselView:(方框是TWO所在的carousel位置)

这是我旋转我的方式iCarousel:
-(IBAction) spin {
[carousel1 scrollByNumberOfItems:-35 duration:10.7550f];
[carousel2 scrollByNumberOfItems:-35 duration:10.7550f];
}
Run Code Online (Sandbox Code Playgroud)
这就是我想做的事情:我想强行让它停在用户选择的索引上.
我这样做了,下面的图片中newViewcontroller包含UIImageView一个按钮,所以当用户点击它时,我会CustomPicker弹出.我CustomPicker包含用户在相机胶卷上拾取的图像.所以每个按钮都有一个发送给我的特定值 iCarouselView.slot1的carousel1和slot2的carousel2.
所以我的问题是旋转旋转木马然后在特定时间使其停止到用户选择的所需图像/索引.
对不起,我的英语不好.

小智 4
这很容易。我以前也做过类似的事情。
在下面的方法中:
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view{
//Configure your view here
.....
//Add a button on each view of the carousel
UIButton * someButton = [[UIButton alloc] initWithFrame:view.bounds];
[someButton setAlpha:0.0];
[someButton addTarget:self action:@selector(fingerLanded:) forControlEvents:UIControlEventTouchDown];
[view addSubview:someButton];
[view bringSubviewToFront:someButton];
//Add a tag - correspond it to the index
someButton.tag = index;
//Make sure the view is user interaction enabled
[view setUserInteractionEnabled:YES];
//Also make sure the button can actually receive touches and there is no view
//blocking touch events from being sent to the button.
return view;
}
Run Code Online (Sandbox Code Playgroud)
还添加
- (void) fingerLanded:(id) sender{
UIButton * theButtonFingerLandedOn = (UIButton *) sender;
//This is the index the user tapped his finger on
NSUInteger index = theButtonFingerLandedOn.tag;
//Scroll to that particular index
[self.carousel scrollToItemAtIndex:index animated:YES];
Run Code Online (Sandbox Code Playgroud)
}
还添加
- (void) viewDidLoad{
//You may need this to enable user interaction on a view flying by
// Look in the - (void)transformItemViews method of the iCarousel library
self.carousel.centerItemWhenSelected = NO;
}
Run Code Online (Sandbox Code Playgroud)
你必须做类似的事情。希望它有帮助:)!!