我想得到用户已经修改过的索引,我已经尝试过几种方法来检测它,但是没有一种是有效的。这是我尝试过的。
func carousel(carousel: iCarousel, didSelectItemAtIndex index: Int) {
print("this has been tapped from Carousel \(index)")
}
func carouselCurrentItemIndexDidChange(carousel: iCarousel) {
let index=carousel.currentItemIndex
print("this is current index \(index) ")
}
func carousel(carousel: iCarousel, viewForItemAtIndex index: Int, reusingView view: UIView?) -> UIView {
let webV:WKWebView!
webV = WKWebView(frame: CGRectMake(10, 10, 250, 250))
if let updatedResource = myDict[index+1]{//name of resource I want to load
let url = NSBundle.mainBundle().URLForResource(updatedResource, withExtension: "html")
let requestObj = NSURLRequest(URL: url!);
webV.loadRequest(requestObj);
let tapGesture = UITapGestureRecognizer(target: self , action: Selector("tapDetected"))
//tapGesture.numberOfTapsRequired = 2
tapGesture.enabled = true
webV.userInteractionEnabled = true
webV.addGestureRecognizer(tapGesture)
// setUserInteractionEnabled = true
print("this has been rendered \(index)")
}
return webV
}
func tapDetected(sender:UISwipeGestureRecognizer) {
print("yes tap has been detected :)")发布于 2016-08-02 21:26:59
可能没有帮助,因为我使用的是目标-C,但是在
- (void)didTap:(UITapGestureRecognizer *)tapGesture 方法。
[_delegate carousel:self didSelectItemAtIndex:index];
NSLog(@"Selected app at index: %d", index);按预期工作。我使用的是iCarousel版本1.8.2
发布于 2022-08-15 23:32:41
这对我有效(注意匿名参数的_标志)
func carousel (_ carousel: iCarousel, didSelectItemAt index: Int) {
}https://stackoverflow.com/questions/38327842
复制相似问题