sfsafariviewcontroller叠加,带有主页按钮不起作用

里查·斯里瓦斯塔瓦

SFSafariViewController需要显示Cookie才能显示网页。我不需要野生动物园搜索栏,所以我有一个隐藏它的覆盖物和一些执行某些任务的按钮。我确实想要完成按钮的功能。由于已经覆盖,完成按钮被隐藏并且不起作用,因此我在下面的代码中进行了尝试。但这效果不佳-

self.presentViewController(sfController, animated: true) {
        let bounds = UIScreen.mainScreen().bounds

        // It can be any overlay. May be your logo image here inside an imageView.
        let overlay = UIView(frame: CGRect(x: 0, y: 0, width: bounds.size.width, height: 65))
        let completedBtn = UIButton()
        let favBtn = UIButton()
        let homeBtn = UIButton()

        homeBtn.setTitle("Home",forState: .Normal)
        homeBtn.setTitleColor(UIColor.whiteColor(), forState: .Normal)
        homeBtn.frame = CGRectMake(20, 25, 200, 35)
        homeBtn.backgroundColor = UIColor(netHex: 0x6F9824)
        homeBtn.addTarget(self, action: #selector(DetailsViewController.HomeBtnAction), forControlEvents: UIControlEvents.TouchUpInside)

        completedBtn.setTitle("Completed",forState: .Normal)
        completedBtn.setTitleColor(UIColor.whiteColor(), forState: .Normal)
        completedBtn.frame = CGRectMake((bounds.size.width - 210), 25, 200, 35)
        completedBtn.backgroundColor = UIColor(netHex: 0x6F9824)
        completedBtn.addTarget(self, action: #selector(DetailsViewController.CompletedAction), forControlEvents: UIControlEvents.TouchUpInside)

        favBtn.setTitle("Favourite", forState: .Normal)
        favBtn.setTitleColor(UIColor.whiteColor(), forState: .Normal)
        favBtn.frame = CGRectMake((bounds.size.width - 420), 25, 200, 35)
        favBtn.backgroundColor = UIColor(netHex: 0x6F9824)
        favBtn.addTarget(self, action: #selector(DetailsViewController.FavouriteAction), forControlEvents: UIControlEvents.TouchUpInside)

        overlay.backgroundColor = UIColor(netHex: 0x435C16)

        overlay.addSubview(favBtn)
        overlay.addSubview(completedBtn)
        overlay.addSubview(homeBtn)
        sfController.view.addSubview(overlay)
}

On click of Home button i have this code - 
func HomeBtnAction(){
        let app = "MyApp://"
        let appUrl = NSURL(string: app)
        if UIApplication.sharedApplication().canOpenURL(appUrl!)
        {
            UIApplication.sharedApplication().openURL(appUrl!)

        }
    }

我的清单看起来像这样-

<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>MyApp</string>
    </array>
    <key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLName</key>
            <string>Test.com.MyApp</string>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>MyApp</string>
            </array>
        </dict>
    </array>

但是在单击“主页”按钮时,什么也没有发生。它没有给出任何错误或警告消息。我也知道,单击“主页”按钮时,我当前的代码将发出警报以再次打开该应用程序,但我也不想这样做。我想要与sfsafariviewcontroller的“完成”按钮完全相同的功能。我们可以做那个工作,也可以覆盖我吗?

提前致谢!并欢迎任何建议。

萨利赫·苏丹(Saleh Sultan)

您为什么不只调用presentViewcontroller dismiss函数。我使用swift 3测试了此源代码。它对我来说正常工作,我可以返回到我的应用程序。

func HomeBtnAction(){
        print("Button Pressed")
        self.dismiss(animated: true, completion: nil)
    }

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

带有主要 NOT IN 的 SQL 查询不起作用

SFSafariViewController完成按钮不起作用

在日食中创建带有图像的按钮不起作用

带有Jquery .html()函数添加的按钮不起作用

带有单选按钮的 getElementById 不起作用

带有Jquery的HTML按钮突出显示不起作用

带有提交按钮的复选框不起作用

“后退”按钮在带有 Kivy 的 Python 中不起作用

iOS模拟器:双击主页按钮有时不起作用

操作栏中的“主页”按钮在Lollipop中不起作用

单击按钮时,叠加 div 不起作用

具有主键的批量复制不起作用

如果还有,按钮不起作用

带有ColognePhonetic的PhoneticFilterFactory不起作用

带有LayoutWeight的LinearLayout不起作用

带有AutoLayout的ScrollView不起作用

带有next()的toggleClass()不起作用

带有Coffescript的角度不起作用

带有参数的RedirectToAction不起作用

带有指针的程序不起作用

带有 webpack 的 Sass 不起作用

带有 getElementById 的函数不起作用

带有 Qwidget 的 KeyPressEvent 不起作用?

提交按钮在包含带有foreach的表格的表单中不起作用

带有类选择器的 Jquery 按钮在 chrome/firefox 中不起作用

在带有模板的Angular ng-bootstrap模态中,关闭和关闭按钮不起作用

带有切换按钮的AngularJS隐藏/显示行不起作用

带有Angular材质的Angular 5-按钮纹波效果不起作用

Android在MaterialButtonToggleGroup中添加带有多行文本的按钮不起作用