iOS图表子类Markerview使用Swift始终在“ xxx-Swift.h”中生成错误

问题描述 投票:0回答:2

MarkerView在“ Charts”框架中,当我使用swift子类化MarkerView时,它将在“ Project-Swift.h”文件中出现Build Error“ Project-Swift .h”Xcode自动生成。

“ TestMV.swift”文件中:

import UIKit

import Charts

class TestMV: MarkerView {

}

“ ProjectName-Swift.h”文件中:

SWIFT_CLASS("_TtC9KCTFunFit6TestMV")

@interface TestMV : ChartMarkerView

- (nonnull instancetype)initWithFrame:(CGRect)frame 

OBJC_DESIGNATED_INITIALIZER;

- (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder 

OBJC_DESIGNATED_INITIALIZER;

@end

“图表”框架中

import Foundation
import CoreGraphics
import AppKit

@objc(ChartMarkerView)
open class MarkerView: NSUIView, IMarker {
     open var offset: CGPoint = CGPoint()

     @objc open weak var chartView: ChartViewBase?

     open func offsetForDrawing(atPoint point: CGPoint) -> CGPoint
     {
        .......
     }
 }

“ TestMV.swift”]中的TestMV子类Markerview

“ ProjectName-Swift.h”中始终生成错误

“图表”]中的Markerview>框架

MarkerView在“图表”框架中,当我使用swift子类化MarkerView时,它将在“ Project-Swift.h”文件中发生“构建错误”,Xcode会自动生成“ Project-Swift.h”。在“ TestMV.swift”文件中:...

ios objective-c swift xcode ios-charts
2个回答
0
投票

尝试将@interface TestMV : ChartMarkerView重命名为@interface TestMV : MarkerView,因为这是您在TestMV类中定义的方式。

供将来参考,a similar question can be found here


0
投票
#import <Charts/Charts-Swift.h>
© www.soinside.com 2019 - 2024. All rights reserved.