OC 中 使用 swfit 代碼.

OC 中 使用 swfit 代碼.

  • Build Setings
    • defines module 設(shè)置為 YES
    • product module name 設(shè)置為項(xiàng)目工程名字(一般默認(rèn)就是項(xiàng)目工程名字)

在需要用到 swift 文件的 類中 引入文件 ProjectName-Swift.h 文件
> ProjectName-Swift.h 文件 是系統(tǒng)創(chuàng)建的, 在工程中找不到, 有時(shí)候也不會(huì)自動(dòng)提醒, 要完全自己手打完整個(gè)文件名字.


OC 項(xiàng)目中 在 oc 文件中 使用 swift 三方庫(kù)

要在 oc 項(xiàng)目中 引入文件 三方庫(kù)名-Swift.h 文件, 這個(gè)文件是系統(tǒng)自動(dòng)生成的.
這樣就可以在 OC 文件中調(diào)用 swift 三方庫(kù)的方法了, 系統(tǒng)會(huì)自動(dòng)把swift 方法映射為 oc 方法.
不過(guò), 某些swift 特性不能轉(zhuǎn)化為 oc , 故 很多swift 方法不會(huì)映射為 oc 方法, 所以有一部分swfit方法 oc 文件不能使用
更多詳細(xì)介紹看兩篇文章


報(bào)錯(cuò):
The behavior of the UICollectionViewFlowLayout is not defined because:
the item height must be less than the height of the UICollectionView minus the section insets top and bottom values, minus the content insets top and bottom values.
The relevant UICollectionViewFlowLayout instance is <KanbanCollectionViewHorizontalLayout: 0x7fa39960c8e0>, and it is attached to <UICollectionView: 0x7fa39a8ba000; frame = (0 0; 375 70); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x60800064fba0>; layer = <CALayer: 0x608000230800>; contentOffset: {0, 0}; contentSize: {187.5, 70}> collection view layout: <KanbanCollectionViewHorizontalLayout: 0x7fa39960c8e0>.
Make a symbolic breakpoint at UICollectionViewFlowLayoutBreakForInvalidSizes to catch this in the debugger.

  1. 在控制器中加上
    self.automaticallyAdjustsScrollViewInsets = NO
    當(dāng)automaticallyAdjustsScrollViewInsets為YES時(shí),它會(huì)找view里的scrollView,并設(shè)置scrollView的contentInset為{64, 0, 0, 0}。如果你不想讓scrollView的內(nèi)容自動(dòng)調(diào)整,將這個(gè)屬性設(shè)為NO(默認(rèn)值YES)。

2.手動(dòng)調(diào)整itemSize的大小
也有可能是, collectionView的itemSize 長(zhǎng)或者寬 大于了 colloectionview. 調(diào)整一下就好了

現(xiàn)在正在看的文章:

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容

  • 發(fā)現(xiàn) 關(guān)注 消息 iOS 第三方庫(kù)、插件、知名博客總結(jié) 作者大灰狼的小綿羊哥哥關(guān)注 2017.06.26 09:4...
    肇東周閱讀 12,251評(píng)論 4 61
  • 唯愿時(shí)光不在逼她,好姑娘永遠(yuǎn)衣襟戴花
    ByJing鯨閱讀 185評(píng)論 1 1
  • 我與他真的好久不見,久到八、九年,久到聽說(shuō)我們的同班小學(xué)同學(xué)有的已經(jīng)當(dāng)上父母,久到我們?cè)僖不夭蝗ツ沁b遠(yuǎn)的小屁孩...
    阿拉米琪家閱讀 330評(píng)論 3 4