1新建類選擇Swift 的時候, 會出現是否選擇生成類似這樣的頭文件, 選擇生成,(用於Swift類調用Oc的類使用的)
2 在Oc的類中聲明 工程的名字加上-Swift.h 類似
3 接下來進入下一個界面的方法就都一樣啦。
present 到Swift 界面 :
SwiftViewController *pushSwift = [[SwiftViewController alloc] init];
//[pushSwift leftReturnBtn];
[self presentViewController:pushSwift animated:YES completion:nil];
Swift 界面返回 Oc界面
self.dismissViewControllerAnimated(true, completion: nil)
接下來說說怎么從Swift 界面跳轉到OC界面
1 在 工程名-Bridging-Header.h這個類中聲明要進入的OC類
如圖:
接下來可以在Swift類中調用啦
如下:
let nextVc : ViewController!
nextVc = ViewController.init()
self.presentViewController(nextVc, animated: true, completion: nil)
聲明可以被別的類調用的屬性的方法
var trantsStr : String = String()//"聲明的屬性不能聯想,只能copy啊";
完整工程鏈接我會發評論里