uiimpactfeedbackgenerator类的有效值范围是什么?
ios Uikit类 uiimpactfeedbackgenerator href =“ https://developer.apple.com/documentation/uikit/uiimpactfeedbackgenerator/3183920-ImpactoccurredWithStrentss” rel =“ nofollow noreferrer”>“ nofollow noreferrer”> factionccurredwithsentsenty 强度
。已记录的声明为(在Objective-C中):
- (void)impactOccurredWithIntensity:(CGFloat)intensity;
截至此问题时,链接的文档页面没有提供有关该intermenty
参数的有效值范围的信息,以及什么效果价值具有。
(范围0到1?0到无穷大?其他一些最大值?允许负值吗?较大的值会产生更强烈的触觉反馈吗? “ https://developer.apple.com/documentation/uikit/uiimpactfeedbackstyle” rel =“ nofollow noreferrer“> uiimpactfeedBackstyle
value ,例如uiimpactfeedbackstyleheheavy
,uiimpactfeedbackgenerator
可以用
?这个问题,一个简单的 google搜索actighoccurredwithStrintsenty
没有任何有意义的结果页。
我的问题:强度
参数的有效值范围是什么,ImpactoccurredWithStrentmenty
方法以及该值有什么具体效果?
The iOS UIKit class UIImpactFeedbackGenerator, in iOS 13+, has an instance method impactOccurredWithIntensity, which takes a single CGFloat
parameter, intensity
. The documented declaration is (in Objective-C):
- (void)impactOccurredWithIntensity:(CGFloat)intensity;
As of the time of this question, the linked documentation page provides no information on what the valid range of values are for that intensity
parameter, and what effect the value has.
(Is the range 0 to 1? 0 to infinity? Some other maximum? Are negative values permitted? Do larger values generate more intense haptic feedback? How does the intensity
value interact with the various UIImpactFeedbackStyle
values, such as UIImpactFeedbackStyleHeavy
, that the UIImpactFeedbackGenerator
can be initialized with?)
Also as of the time of this question, a simple Google search for impactOccurredWithIntensity
yields no meaningful results beyond that linked Apple documentation page.
My question: What are the valid range of values for the intensity
parameter of the impactOccurredWithIntensity
method, and what specific effect does the value have?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
强度
参数是0.0
和1.0
之间的值,旨在表示影响力的力量。 (此方法的标题声明和文档既表示;每种冲击都会播放的触觉振动的体积/强度。当您初始化影响反馈生成器时,您选择的
样式
旨在描述撞击中涉及的UI元素的物理属性,例如它们是轻,重,柔软的还是刚性的。 会影响发生冲击时播放的触觉波形的类型样式
在uiimpactFeedGenerator
初始化时烤入uiimpactFeedGenerator
是因为style
应在相同的UI元素的多个影响中保持一致。另一方面,强度
是每个影响的参数,因为它通常是UI元素相撞时移动的速度的函数。由您决定哪些参数最适合您的用例。选择如何将不同的冲击速度映射到标准化
0.0-1.0
intense
的范围是您可以定义的。最终,您需要在真实设备上进行实验并调整参数,以产生令人信服的体验,从而增加交互作用,而不会分散注意力。The
intensity
parameter is a value between0.0
and1.0
, which is intended to represent the force of the impact. (The header declaration and documentation for this method both indicate this; the documentation may have been updated since you asked the question originally.) In terms of how it affects the haptic output, you can think ofintensity
as the volume/strength of the haptic vibration that gets played for each impact.When you initialize an impact feedback generator, the
style
you choose is intended to describe the physical attributes of the UI elements involved in the impact, for example whether they are light, heavy, soft, or rigid. Thestyle
affects the type of haptic waveform that is played when an impact occurs, for example whether the vibration is more of a quick sharp tap, a dull thud, etc.The reason that the
style
is baked in to theUIImpactFeedbackGenerator
when it is initialized is because thestyle
should remain consistent across multiple impacts for the same UI elements. On the other hand, theintensity
is a parameter for each impact, as it's generally a function of how fast the UI elements were moving when they collided.It's up to you to determine which parameters work best for your use case. Choosing how to map different impact velocities to the normalized
0.0 - 1.0
range ofintensity
is something you get to define. Ultimately, you'll want to experiment and tune the parameters on a real device to produce a compelling experience that adds to the interaction, without being distracting.