小编Raj*_*han的帖子

表情符号键盘 SwiftUi

我想制作一个表情符号文本框,可以在其中编写唯一的表情符号,并且更好,以便出现表情符号键盘。表情符号键盘是标准的。我正在用 SwiftUI 编写一个程序。找到了这段代码,它对我有用吗?如果是这样,你如何使用它?如果没有,您需要哪一个?

\n

感谢!

\n
class EmojiTextField: UITextField {\n\n       // required for iOS 13\n       override var textInputContextIdentifier: String? { "" } // return non-nil to show the Emoji keyboard \xc2\xaf\\_(\xe3\x83\x84)_/\xc2\xaf \n\n        override var textInputMode: UITextInputMode? {\n            for mode in UITextInputMode.activeInputModes {\n                if mode.primaryLanguage == "emoji" {\n                    return mode\n                }\n            }\n            return nil\n        }\n\n    override init(frame: CGRect) {\n            super.init(frame: frame)\n\n            commonInit()\n        }\n\n        required init?(coder: NSCoder) {\n            super.init(coder: coder)\n\n             commonInit()\n        }\n\n        func commonInit() {\n            NotificationCenter.default.addObserver(self,\n                                                   selector: #selector(inputModeDidChange),\n                                                   name: UITextInputMode.currentInputModeDidChangeNotification,\n                                                   object: nil)\n …
Run Code Online (Sandbox Code Playgroud)

emoji swift

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

参数类型“Any”预计是类或类约束类型的实例

我正在尝试构建一个提醒应用程序,但遇到了问题。

我有一个函数,

override func prepare(for segue: UIStoryboardSegue, sender: Any?)
{
    
    if saveButton === sender {
        let name = reminderTextField.text
        var time = timePicker.date
        let timeInterval = floor(time.timeIntervalSinceReferenceDate/60)*60
        time = NSDate(timeIntervalSinceReferenceDate: timeInterval) as Date
        
        //build; notification
        let notification = UILocalNotification()
        notification.alertTitle = "Reminder"
        notification.alertBody = "Don't forget to \(name!)!"
        notification.fireDate = time
        notification.soundName = UILocalNotificationDefaultSoundName
        
        UIApplication.shared.scheduleLocalNotification(notification)
        
        reminder = Reminder(name: name!, time: time as NSDate, notification: notification)
    }
}
Run Code Online (Sandbox Code Playgroud)

它说,参数类型“任何”预计是类或类约束类型的实例, 我该如何解决这个问题?

ios swift

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

swift ×2

emoji ×1

ios ×1