利用UINotificationFeedbackGenerator在Python中的应用

2024-04-25 07:34:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我想在pythonista中使用uinotificationfeedbackgenerator

from objc_util import *
feedbackGenerator = ObjCClass('UINotifcationFeedbackGenerator')

feedbackGenerator = feedbackGenerator.alloc().init()
feedbackGenerator.notificationOccurred(0)

但是运行这个程序会导致应用程序崩溃,错误文件是

called more times than the feedback engine was activated

所以搜索它,似乎反馈生成器是不安全的,但是在主线程上使用也不起作用(或者我只是用错了)。奇怪的是,通过将其添加到ui调用的方法中here

谢谢你的帮助!你知道吗


Tags: fromimport程序应用程序init错误utilpythonista
1条回答
网友
1楼 · 发布于 2024-04-25 07:34:54

可能有点晚;-),但是:您正在覆盖将导致崩溃的反馈生成器:

feedbackGenerator = feedbackGenerator.alloc().init()

试试这个:

f = feedbackGenerator.alloc().init()
f.notificationOccurred(0)

相关问题 更多 >