gpt4 book ai didi

ios - iCarousel 获取用户点击索引

转载 作者:行者123 更新时间:2023-11-30 13:14:59 25 4
gpt4 key购买 nike

我想获取用户点击的索引。我尝试了多种方法来检测它,但都不起作用。这是我尝试过的。

   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 :)")

最佳答案

可能没有帮助,因为我使用的是 Objective-C,但在

中检测到了点击
- (void)didTap:(UITapGestureRecognizer *)tapGesture 

方法。

 [_delegate carousel:self didSelectItemAtIndex:index];
NSLog(@"Selected app at index: %d", index);

按预期工作。我使用的是 iCarousel 版本 1.8.2

关于ios - iCarousel 获取用户点击索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38327842/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com