首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iPadOS 13.4不调用trackpad IUIPointerInteractionDelegate方法GetStyleForRegion

iPadOS 13.4不调用trackpad IUIPointerInteractionDelegate方法GetStyleForRegion
EN

Stack Overflow用户
提问于 2020-05-17 17:25:11
回答 1查看 160关注 0票数 0

我正在工作的iPadOS 13.4应用程序,与触控板输入工作。我已经做了很多工作,比如双指滚动,右键单击(双指或控制-点击),按一下-缩放,等等。我有另一个控件,它可以很好地处理触控板,但是它是一个自定义的文本控件,所以我需要使用UIPointerInteraction API。将圆柱形光标从一个圆圈改变为一个i波束。

我修改了苹果提供的Swift示例代码项目,并在视图上显示了一个i波束,这样我就知道如果系统将调用我的styleFor: region方法,那么该怎么办,但是就是不会称它为。目前还没有对Xamarin进行文档化;最好的例子是程序集浏览器,以及提到方法签名的这里。我在Xamarin.iOS 13.16.1。

代码语言:javascript
复制
public class MyClass: UIView, IUIPointerInteractionDelegate {

    ...

    initalization_code() {
        ...
        UIPointerInteraction interaction = new UIPointerInteraction(this);
        this.AddInteraction(interaction);
    }

    public UIPointerStyle GetStyleForRegion(UIPointerInteraction interaction, UIPointerRegion region) {
        // this code is never called
        const float HEIGHT = 30f;
        return UIPointerStyle.Create(UIPointerShape.CreateBeam((nfloat)HEIGHT, UIAxis.Vertical), UIAxis.Vertical);
    }
}

要让iOS调用C#代码中的GetStyleForRegion,我需要做什么?

EN

回答 1

Stack Overflow用户

发布于 2020-05-17 23:26:33

添加此导出注释完成了以下工作:

代码语言:javascript
复制
[Export("pointerInteraction:styleForRegion:")]
public UIPointerStyle GetStyleForRegion(UIPointerInteraction interaction, UIPointerRegion region) {
    // this code gets called now!
    const float HEIGHT = 30f;
    return UIPointerStyle.Create(UIPointerShape.CreateBeam((nfloat)HEIGHT, UIAxis.Vertical), UIAxis.Vertical);
}

现在调用该方法。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61855916

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档