在Swift中使用iosMath [英] Using iosMath in Swift

查看:67
本文介绍了在Swift中使用iosMath的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于iosMath是用Objective C编写的,我如何在iOS的Swift中使用 iosMath ?还是有另一种方法可以用Swift显示数学公式?

how can I use iosMath in Swift on iOS, because iosMath is written in Objective C? Or is there another way to display mathematical formulas with Swift?

推荐答案

我将使其尽可能快:

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

1.) install cocoaPods (open up terminal and write sudo gem install cocoapods)

2.)从终端更改目录到您的项目,然后初始化cocoaPods并编辑Podfile,如下所示:

2.) From terminal change directory to your project and init cocoaPods and edit the Podfile like this:

cd /ProjectFolder
pod init
nano podFile 

(打开pod文件,在其中粘贴pod repo),应如下所示:

(opens the podfile, where you paste the pod repo) , should look like this:

# 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并通过以下方式安装:

save podfile and install via:

pod install

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

from now, use the workspace file instead of the project file... We are done installing the pod you need right now...

现在有点棘手->您需要从现在开始将新的Objective-C文件添加到项目中(因此只需新建文件-> Objective-C文件并选择create bridged标头即可),您只需删除已创建的文件(但不是桥接头)

Now it gets a little bit tricky -> You need to add new Objective-C file into the project (so just New File -> Objective-C file and select create bridging header) from now, you can just delete the created file (BUT NOT THE BRIDGING HEADER)

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

from now, you can use the Objective-C framework just as it was swift framework,don't forget to import that framework into classes you will use it:

    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.
    }


}

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

Hope this helps, wish happy coding! :)

这篇关于在Swift中使用iosMath的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆