【问题标题】:Present VC modally above other VC - both touchable以模态方式将 VC 呈现在其他 VC 之上 - 两者都是可触摸的
【发布时间】:2017-07-04 17:26:21
【问题描述】:

我想在另一个 VC 上方展示一个 VC,但希望两者都可以点击和负责。

我有一个文本字段,可以打印出每个 @-sign 后面的字符串。

写@时,我有一个 VC,它在第一个 VC 上方弹出一个小表格视图,以后应该代表名称包含打印输出字符串的用户。

我需要第一个 vc 仍然负责,因为目前我无法单击第一个 VC 上的按钮和文本字段,当第二个 VC 弹出时,即使我可以看到所有内容(将背景设置为清除)。

        if commentTextField.text!.contains("@"){
        print("changed textField")
        let vc = self.storyboard?.instantiateViewController(withIdentifier: "suggestedUsersViewController") as  UIViewController!
        vc?.modalPresentationStyle = .overCurrentContext
        vc?.view.backgroundColor = .clear


        present(vc!, animated: true, completion: nil)

    }

我如何得到@- 符号后面的帖子

        let caption = commentTextField.text


    let words = caption?.components(separatedBy: CharacterSet.whitespacesAndNewlines)
    for var word in words! {
            if word.hasPrefix("@") {
                word = word.trimmingCharacters(in: CharacterSet.punctuationCharacters)

                print("wort ist", word)
            }
    }

目前它只是弹出第一个 vc,然后它不再可点击,我无法更改文本字段

图片

【问题讨论】:

    标签: ios swift modalviewcontroller


    【解决方案1】:

    present 函数将使第二个视图控制器覆盖整个页面,您将无法再从屏幕访问顶部视图控制器下方的视图控制器。

    要实现您的目标,您需要在视图上放置UITableView,然后继续显示或隐藏该视图。如果你真的想要另一个视图控制器,你可以创建一个包含视图并嵌入到另一个view controller,就像这样

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-09-11
    • 1970-01-01
    • 2013-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多