My Swift-Class通过以下代码定义了一个initWith ..方法
convenience init(controlType: ApplePencilControlType) {
self.init(frame: CGRect())
type = controlType
self.frame = self.controlFrame
if type == .zoom {
zoomSlider = UISlider(frame: CGRect(x: 10, y: 10, width: 100, height: 20))
if let slider = zoomSlider {
self.addSubview(slider)
}
}
else if type == .toLeft || type == .toRight {
imageView = UIImageView(frame: CGRect(x: 5, y: 5, width: 20, height: 20))
if let imgView = imageView {
if let img = type.image {
imgView.image = img
}
self.addSubview(imgView)
}
}
}
尝试通过以下Objective-C代码调用此方法会使Xcode显示错误。
- (void)presentOrHidePencilControls {
self.apToLeft = [[ApplePencilControl alloc] initWithControlType:ApplePencilControlTypeToLeft];
}
错误为No visible @interface for 'ApplePencilControl' declares the selector 'initWithControlType:'
我该怎么做,所以我可以从Objective-C调用这个初始化程序? " Project / Modul-Swift.h"已导入。
答案 0 :(得分:0)
我必须在同一个班级的枚举定义中插入CREATE TABLE #Table1
(
rno int identity(1,1),
ccp varchar(50),
[col1] INT,
[col2] INT,
[col3] INT,
col4 as [col2]/100.0
);
INSERT INTO #Table1
(ccp,[col1],[col2],[col3])
VALUES ('ccp1',15,10,1100),
('ccp1',20,10,1210),
('ccp1',30,10,1331),
('ccp1',40,10,1331),
('ccp2',10,15,900),
('ccp2',15,15,1000),
('ccp2',20,15,1010);
select t.*, col3-s
from(
select *, rn = row_number() over(partition by ccp order by rno)
from #Table1
) t
cross apply (
select s=sum(pwr*col1)
from(
select top(rn)
col1, pwr = power(1+col4, rn + 1 - row_number() over(order by rno))
from #Table1 t2
where t2.ccp=t.ccp
order by row_number() over(order by rno)
)t3
)t4
order by rno;
和@objc
。