我尝试按照本教程实施iCarousel:https://medium.com/@arb1nsnmgl/icarousel-walkthrough-swift-3-0-887554155242 但是当尝试实现@protocol时,它会给我4条错误消息:
当前代码如下:
import UIKit
class ViewController: UIViewController {
@IBOutlet var carouselView: iCarousel!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
//Testing
@protocol iCarouselDataSource <NSObject>
-(NSInteger)numberOfItemsInCarousel:(iCarousel *)carousel;
-(UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(nullable UIView *)view;
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
答案 0 :(得分:1)
您将其添加到错误的位置,请删除
@protocol iCarouselDataSource <NSObject>
-(NSInteger)numberOfItemsInCarousel:(iCarousel *)carousel;
-(UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(nullable UIView *)view;
通过viewDidLoad
方法。
以上方法都是委托方法。并且您需要按照教程中所示添加它。
为此检查11点。
还要确认代表,如第8点所示。