小编MLy*_*yck的帖子

如何在 vite 或 rollup 中保留全局变量名?(窗口.FB)

我正在尝试在我的应用程序中设置“使用 facebook 登录”功能。

一切都在本地运行良好,或者如果我不缩小我的包。

然而,当我缩小捆绑输出时,有一个全局函数恰好被缩小为FB( window.FB),这完全破坏了 facebook SDK。

Facebook 不提供任何使用任何其他变量名称的方法。因此,我试图弄清楚如何“保留”或防止我的捆绑程序 viteJS / Rollup 将另一个全局函数名称缩小为FB.

正在缩小的全局函数来自 nodejs,并且可能是通过某个 npm 包导入的,但我不确定是哪一个。(即使我能找到它,我使用它也是有原因的,并且可能没有好的替代方案)。

这是保存在全局窗口上并缩小为“FB”的随机nodejs函数: https ://github.com/nodejs/node/blob/4b6e4c1eb110e0be671ec5972bf280d2bf3892d8/lib/_stream_read.js#L497

如何防止window.FB全局变量名被该函数占用?(当然要打开 minify)。

我尝试设置build.outputs.globals.FB为“TEST”,并window.FB在我的 index.ts 文件中进行定义,看看它是否会强制它不使用相同的名称进行缩小。但这似乎并不影响捆绑器。

javascript facebook rollup node.js vite

5
推荐指数
1
解决办法
1696
查看次数

Swift - 将UIPageViewController控件带到前面

在填写完整个屏幕后,我将点缀的UIPageControls带到了前面,我遇到了一些麻烦.

这是我目前的代码:

    import UIKit


class ViewController: UIViewController, UIPageViewControllerDataSource {

    //This outlet wasn't originally there. Added a UIPageControl as an attempt to solve my issue
    @IBOutlet var pageControl: UIPageControl!

    var pageViewController : UIPageViewController?
    var pageTitles : Array<String> = ["Orc", "Elven", "Undead"]
    var pageImages : Array<String> = ["Plain_Orc.png", "Plain_Elf.png", "Plain_Undead.png"]
    var currentIndex : Int = 0


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

        self.pageViewController = UIPageViewController(transitionStyle: .Scroll, navigationOrientation: .Horizontal, options: nil) …
Run Code Online (Sandbox Code Playgroud)

uipageviewcontroller swift xcode6

1
推荐指数
1
解决办法
5519
查看次数

swift - touchID需要很长时间才能加载

我正在努力将touchID集成到我的应用程序中.这个过程非常简单,但即使只是使用我的虚拟数据,它在执行任务之前需要大约5秒的时间来验证我的指纹.

这是我的代码:

func requestFingerprintAuthentication() {
    let context = LAContext()
    var authError: NSError?
    let authenticationReason: String = "Login"

    if context.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error: &authError) {
        context.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: authenticationReason, reply: {
            (success: Bool, error: NSError?) -> Void in
            if success {
                println("successfull signin with touchID")
                self.emailInputField.text = "john.doe@gmail.com"
                self.passwordInputField.text = "password"
                self.signIn(self.signInButton)
            } else {
                println("Unable to Authenticate touchID")
            }
        })
    }
}
Run Code Online (Sandbox Code Playgroud)

即使使用虚拟数据,也需要花费太长时间.

当我正常登录时,通过在我的输入字段中键入电子邮件和密码,signIn()函数立即运行.

看看它是否有问题.我尝试用2行替换它,只需将我带到正确的viewController.但是在对我的指纹进行身份验证后仍需要几秒钟.

我知道这不是手机,也不是touchID.因为它立即运行我的println("使用touchID成功登录").之后是什么,由于某种原因它需要几秒钟才能运行?

任何帮助解释这一点将不胜感激!

ios touch-id swift xcode6

1
推荐指数
1
解决办法
656
查看次数

快速获取另一个 ViewController 中选定单元格的数据(以编程方式)

这个问题已经回答过很多次了。但是我能找到的答案对我不起作用,因为我似乎无法调用单元格的类。

进一步解释:

我有一个带有 UITable 的 viewController。单元格在 UITableViewCell 类中配置。(我需要从这个类中提取信息)

我的“细胞类”被称为 mySuggestionsCel

这是我的“didSelectRowAtIndexPath”代码

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    tableView.allowsSelection = false

    var selectedCell:UITableViewCell = tableView.cellForRowAtIndexPath(indexPath)!

    var VC = detaiLSuggestion_VC()
    self.navigationController?.pushViewController(VC, animated: true)


    if selectedCell.backgroundColor == UIColor.formulaFormColor() {
        selectedCell.backgroundColor = UIColor.formulaMediumBlue()
        UIView.animateWithDuration(0.5, animations: {
            selectedCell.backgroundColor = UIColor.formulaFormColor()
        })
    } else {
        selectedCell.backgroundColor = UIColor.formulaGreenColor()
        UIView.animateWithDuration(0.5, animations: {
            selectedCell.backgroundColor = UIColor.formulaLightGreenColor()
        })
    }
}
Run Code Online (Sandbox Code Playgroud)

我试着做

mySuggestionsCell.someVariable

我也试过 selectedCell.someVariable

都没有工作。

我需要从我的单元格类中的 detailSuggestion_VC() 中获取此信息。但是它需要提取的数据是被选中的特定单元格的数据。这就是为什么我在让它工作时遇到了一些麻烦。

我环顾了一会。但是找不到这个特定问题的任何问题或答案。

任何帮助将不胜感激

uitableview tableviewcell ios swift

0
推荐指数
1
解决办法
4609
查看次数