我有一个使用UICollectionView的iOS应用程序。我现在正在为苹果电脑创建应用程序,所以我尝试使用NSCollectionView,但是我不确定我应该从哪里开始。我正在尝试添加下面的代码,但它似乎不可用。我哪里错了?谢谢
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 30
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCellWithReuseIdentifier("Cell", forIndexPath: indexPath) as ProjectsCellCollectionViewCell
cell.textLabel.text = "\(indexPath.section):\(indexPath.row)"
return cell
}谢谢。
我已经遵循了快速入门指南,并且我被困在这一部分:
-(void)insertObject:(PersonModel *)p inPersonModelArrayAtIndex:(NSUInteger)index {
[personModelArray insertObject:p atIndex:index];
}
-(void)removeObjectFromPersonModelArrayAtIndex:(NSUInteger)index {
[personModelArray removeObjectAtIndex:index];
}
-(void)setPersonModelArray:(NSMutableArray *)a {
personModelArray = a;
}
-(NSArray*)personModelArray {
return personModelArray;
}我似乎无法将这些添加到我的ViewController.swift文件中。有什么建议吗?
发布于 2015-03-21 20:00:22
iOS对UI元素使用UIKit,而Mac使用AppKit。它们之间有一些很大的区别,主要是因为iOS是用于基于移动触摸的界面,而Mac是用于桌面键盘/鼠标界面。在iOS和Mac之间共享的是Foundation。如果在Mac上有对应的类,你通常可以用NS代替UI来找到你正在寻找的类。你的代码不会工作,因为Mac上没有UICollectionView。
然而,正如你似乎已经注意到的那样,苹果为其提供了quick start guide的NSCollectionView。
https://stackoverflow.com/questions/29182082
复制相似问题