【问题标题】:What is the Objective-c equivalent of the Swift customAnnotation.coordinateMode = .relativeYSwift customAnnotation.coordinateMode = .relativeY 的 Objective-c 等价物是什么
【发布时间】:2018-05-08 01:51:01
【问题描述】:

我在注释上有以下来自 SciChat Tutorial07 的 Swift 代码。 我在 Objective C 中寻找功能等效的代码。不幸的是我找不到任何相关的例子。 SciChart 社区的任何人都可以帮忙吗?谢谢!

let totalCapacity = 500.0
// annotation collection property, used to store all annotations
let annotationGroup = SCIAnnotationCollection()

if (i%100 == 0){

        let customAnnotation = SCICustomAnnotation()
        let customAnnotationContentView = UILabel(frame: CGRect.init(x: 0, y: 0, width: 10, height: 10))
        customAnnotationContentView.text = "Y"
        customAnnotationContentView.backgroundColor = UIColor.lightGray

        customAnnotation.contentView = customAnnotationContentView
        customAnnotation.x1 = SCIGeneric(i)
        customAnnotation.y1 = SCIGeneric(0.5)
        customAnnotation.coordinateMode = .relativeY

        // adding new custom annotation into the annotationGroup property
        annotationGroup.add(customAnnotation)

        // removing annotations that are out of visible range
        let customAn = annotationGroup.item(at: 0) as! SCICustomAnnotation

        if(SCIGenericDouble(customAn.x1) < Double(i) - totalCapacity){
            // since the contentView is UIView element - we have to call removeFromSuperView method to remove it from screen
            customAn.contentView.removeFromSuperview()
            annotationGroup.remove(customAn)
        }

【问题讨论】:

    标签: objective-c swift annotations scichart


    【解决方案1】:

    看起来您需要等效的 Objective-C 常量。

    documentation,您的坐标模式的枚举选项是:

    SCIAnnotationCoordinate_Absolute
    SCIAnnotationCoordinate_Relative
    SCIAnnotationCoordinate_RelativeX
    SCIAnnotationCoordinate_RelativeY
    

    您可能需要 SCIAnnotationCoordinate_RelativeY。

    【讨论】:

    • 感谢您的反馈。我面临的问题是,Objective-c 中似乎没有对应于 annotationGroup.add(customAnnotation) 和 annotationGroup.remove(customAn) 的“添加”和“删除”注释方法。我找不到任何东西 - 或者我是瞎子:-)
    • SCIAnnotationCollection 在 Objective-C 中似乎有 'add' 和 'remove' 方法,就像在 Swift 中一样,例如在这个例子中:scichart.com/documentation/ios/v2.x/…
    • 也许您可以发布您在 Objective-C 中实现这一点的尝试,并分享什么不起作用?
    • 感谢您的反馈。 “添加”和“删除”都工作正常。我缺少在您的示例代码中找到的正确语法。谢谢!
    • 我只有一个问题。添加文本注释时:SCITextAnnotation * annotation1 = [SCITextAnnotation new]; annotation1.text = @"myText"; [self.surface.annotations 添加:annotation1];而不是“myText”,我在表面上得到了文本“SciChart”。我在我的 iOS 版 SciChart 试用版和购买版中都看到了这种行为。我没有分配 annotation1.text = @"SciChart";在我的代码中。为什么会这样?
    猜你喜欢
    • 2014-07-28
    • 2023-03-18
    • 2017-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-25
    • 1970-01-01
    • 2013-12-01
    相关资源
    最近更新 更多