Nativescript iOS CandleStickSeries/OhlcSeries 'Unrecognized Selector' 错误

Nativescript iOS CandleStickSeries/OhlcSeries 'Unrecognized Selector' Error

我在 iOS (See the code here.) 上使用 NativeScript Angular 演示代码,我收到控制台调试错误:

(CoreFoundation) -[NSNull y]: unrecognized selector sent to instance 0x11194cfc0

Process 10889 stopped

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)

frame #0: 0x0000000111f4bab0 libunwind.dylib`libunwind::CFI_Parser::decodeFDE(libunwind::LocalAddressSpace&, unsigned long long,

libunwind::CFI_Parser::FDE_Info*, libunwind::CFI_Parser::CIE_Info*) + 26

libunwind.dylib`libunwind::CFI_Parser::decodeFDE:

-> 0x111f4bab0 <+26>: movl (%r15), %r12d

0x111f4bab3 <+29>: leaq 0x4(%r15), %rbx

0x111f4bab7 <+33>: movl [=20=]xffffffff, %eax ; imm = 0xFFFFFFFF

0x111f4babc <+38>: cmpq %rax, %r12

Target 0: (test) stopped.

当我加载 CandleStickSeries 或 OhlcSeries 演示时。它锁定了 UI,我必须重新启动应用程序。打字稿与示例代码完全一致

我已成功加载 PieSeries、SplineAreaSeries 和 AreaSeries 图表,没有任何问题。

这是组件的 html 代码:

<RadCartesianChart tkExampleTitle tkToggleNavButton>

    <DateTimeCategoricalAxis 
        tkCartesianHorizontalAxis 
        dateFormat="yyyy-MM-dd"
        verticalLocation="Bottom">
    </DateTimeCategoricalAxis>

    <LinearAxis tkCartesianVerticalAxis></LinearAxis>

    <OhlcSeries 
        tkCartesianSeries 
        categoryProperty="Date" 
        openPropertyName="Open" 
        highPropertyName="High" 
        lowPropertyName="Low" 
        closePropertyName="Close"
        [items]="ohlcSourceItems">
    </OhlcSeries>

</RadCartesianChart>

tns-ios版本是4.1.1,虽然我也用4.1.0测试过。 nativescript-ui-chart 版本是 ^3.6.1 虽然我也测试了不同的版本并且得到了相同的结果。

我不知道是什么导致了这个错误。当我删除 categoryProperty="Date"(这很愚蠢,我知道)属性 错误消失,图表仍然没有加载(即使没有像 Android 版本那样的错误) .我重新排列了属性,将它们删除并替换为在各自 API 页面上找到的属性,但似乎找不到解决方案。

我最近从 NativeScript 4.0 更新到 4.1 以查看是否可以解决该错误,但没有。

我已经在从 iPhone 6 到 iPhone X 的每个 xcode 硬件模拟器中测试了这个,我在尝试加载图表时遇到了同样的错误.

在 Android,这些图表很管用。

只是为了好玩,这是我正在使用的 "obfuscated" package.json(请记住,当我按原样 运行 示例代码时,仍然会出现此错误):

 {
  "description": "Test",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "org.nativescript.test",
    "tns-android": {
      "version": "4.1.3"
    },
    "tns-ios": {
      "version": "4.1.1"
    }
  },
  "dependencies": {
    "@angular/animations": "^5.2.11",
    "@angular/common": "^5.2.11",
    "@angular/compiler": "^5.2.11",
    "@angular/core": "^5.2.11",
    "@angular/forms": "^5.2.11",
    "@angular/http": "^5.2.11",
    "@angular/platform-browser": "^5.2.11",
    "@angular/platform-browser-dynamic": "^5.2.11",
    "@angular/router": "^5.2.11",
    "@types/lodash": "^4.14.110",
    "lodash": "^4.17.10",
    "moment": "^2.22.2",
    "nativescript-angular": "~5.3.0",
    "nativescript-couchbase": "^1.0.18",
    "nativescript-gradient": "^2.0.1",
    "nativescript-pulltorefresh": "^2.1.1",
    "nativescript-svg": "^1.3.4",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-toast": "^1.4.6",
    "nativescript-ui-autocomplete": "^3.7.1",
    "nativescript-ui-chart": "*",
    "node": "^8.11.3",
    "reflect-metadata": "~0.1.8",
    "rxjs": "^5.5.11",
    "tns-core-modules": "^4.1.0",
    "zone.js": "~0.8.2"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^5.2.11",
    "@ngtools/webpack": "~1.9.4",
    "@types/jasmine": "^2.8.8",
    "babel-traverse": "6.26.0",
    "babel-types": "6.26.0",
    "babylon": "6.18.0",
    "clean-webpack-plugin": "~0.1.19",
    "copy-webpack-plugin": "~4.3.0",
    "css-loader": "~0.28.7",
    "extract-text-webpack-plugin": "~3.0.2",
    "husky": "^0.14.3",
    "lazy": "1.0.11",
    "lint-staged": "^7.2.0",
    "nativescript-dev-sass": "^1.5.0",
    "nativescript-dev-typescript": "^0.7.2",
    "nativescript-dev-webpack": "^0.11.0",
    "nativescript-worker-loader": "~0.8.1",
    "prettier": "^1.13.7",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.2.1",
    "sass-loader": "~6.0.6",
    "node-sass": "^4.0.0",
    "tslint": "^5.10.0",
    "typescript": "~2.6.2",
    "uglifyjs-webpack-plugin": "~1.1.6",
    "webpack": "~3.10.0",
    "webpack-bundle-analyzer": "^2.13.1",
    "webpack-sources": "~1.1.0"
  },
  "author": "me"
}

终于...

这是我试图为自己的个人项目工作的 html 代码。显然,如果演示代码不起作用,那么我的也不会。但这里是:

<StackLayout  backgroundColor="rgba(0,0,0,0.7)" borderRadius="3">
  <RadCartesianChart>
    <OhlcSeries 
      tkCartesianSeries
      seriesName="financialChart"
      [items]="ohlcSourceItems"
      verticalAxis="LinearAxis"
      horizontalAxis="DateTimeCategoricalAxis"
      showLabels="false"
      selectionMode="none"
      openPropertyName="Open" 
      highPropertyName="High" 
      lowPropertyName="Low"
      categoryProperty="Date"
      closePropertyName="Close">
    </OhlcSeries>
    <DateTimeCategoricalAxis 
      tkCartesianHorizontalAxis
      majorTickIntervalProperty
      majorTickInterval="5"
      dateFormat="MM/dd"
      dateTimeComponent="Day"
      verticalLocation="Bottom"
      labelSize="12"
      labelMargin="10"
      labelTextColor="#ffffff"
      lineColor="#ffffff"
      plotMode="BetweenTicks">
    </DateTimeCategoricalAxis>
    <LinearAxis 
      tkCartesianVerticalAxis 
      [minimum]="smallest"
      [maximum]="largest"
      labelLayoutMode="Outer"
      labelTextColor="#ffffff"
      labelSize="12"
      labelMargin="10"
      lineColor="#ffffff">
    </LinearAxis>
  </RadCartesianChart>
</StackLayout>

所以这里的答案与我发送到图表的数据有关...而不是图表的属性。

我正在使用 moment js 来格式化日期字符串:

const date = (moment(arr.time * 1000).format('YYYY/MM/DD')).toString();

原来图表需要格式 'DD/MM/YYYY' 才能工作。

我将代码更新为

const date = (moment(arr.time * 1000).format('DD/MM/YYYY')).toString();

并且 iOS 图表启动了。

我假设 selector 这个词在

unrecognized selector sent to instance

指包含数据的数据对象,instance 表示图表属性。

::回到电脑洞穴::