gpt4 book ai didi

objective-c - iCarousel in swift version 1.2 报错(candidate is not Objc but protocol requires it)

转载 作者:可可西里 更新时间:2023-10-31 23:58:08 25 4
gpt4 key购买 nike

我在 swift 1.2 中收到以下错误:'RootViewController' does not conform to protocol 'iCarouselDataSource'

在下面的类中,当我尝试实现第三方库 iCarousel 时:

class RootViewController: UIViewController,iCarouselDataSource,iCarouselDelegate
{...}

自动修复工具在此方法中放置一个符合协议(protocol)的@objc 标记:

@objc func carousel(carousel: iCarousel!, viewForItemAtIndex index: Int, var reusingView view: UIView?) -> UIView?
{}

但随后出现另一个错误:Method cannot be marked @objc because the type of the parameter 3 cannot be represented in Objective-C

感谢任何帮助或线索,谢谢!

最佳答案

从 reusingView 中删除 var,例如:

func carousel(carousel: iCarousel!, viewForItemAtIndex index: Int, reusingView view: UIView!) -> UIView! {
var newView = view
if newView == nil {
//create new view
}
//update data
return newView
}

关于objective-c - iCarousel in swift version 1.2 报错(candidate is not Objc but protocol requires it),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29611324/

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