ios - 在 Swift 中使用 iosMath

标签 ios objective-c swift

我如何使用 iosMath在 iOS 上的 Swift 中,因为 iosMath 是用 Objective C 编写的?还是有其他方法可以使用 Swift 显示数学公式?

最佳答案

我会尽快完成:

1.) 安装 cocoaPods(打开终端并输入 sudo gem install cocoapods)

2.) 从终端更改目录到您的项目并初始化 cocoaPods 并像这样编辑 Podfile:

cd /ProjectFolder
pod init
nano podFile 

(打开 podfile,在其中粘贴 pod 存储库),应该如下所示:

# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'mathExample' do
  # Comment the next line if you're not using Swift and don't want to use dynam$
  use_frameworks!

  # Pods for mathExample

  pod 'iosMath'

end

保存 podfile 并通过以下方式安装:

pod install

从现在开始,使用工作区文件而不是项目文件...我们现在已完成安装您需要的 pod...

现在有点棘手 -> 你需要将新的 Objective-C 文件添加到项目中(所以只需新建文件 -> Objective-C 文件并选择创建桥接 header )从现在开始,你可以删除创建的文件(但不是桥接头文件)

从现在开始,您可以像使用 swift 框架一样使用 Objective-C 框架,不要忘记将该框架导入到您将使用它的类中:

    import UIKit
//Importing our module
    import iosMath


class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        print(iosMathVersionNumber)
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

希望这对您有所帮助,祝您编码愉快! :)

关于ios - 在 Swift 中使用 iosMath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44228429/

相关文章:

iphone - 在 iOS 中将事件添加到生日日历

iphone - MKCoordinateRegionMakeWithDistance 没有在 MapView 上设置正确的区域

ios - 将一个 NSObject 替换为另一个并保存在 coredata 中

ios - 在 XCode 中的新 Mac 上打开项目后团队签名不起作用

objective-c - AVAudioPlayer不适用于(NSString *)文件名

ios - 如何在 Swift 4 中解码 JSON(JSON Web token )?

iphone - Spotify/Rdio 底部工具栏 View Controller 转换

objective-c - 如何在 Swift 中覆盖 Objective-c 类函数?

快速隐藏后退按钮

ios - UIDocumentInteractionController 不会在 iOS 11 中打开其他应用程序