未找到 CGRectMake 符号
CGRectMake Symbol not Found
我正在尝试声明一些 CoreGraphics 函数,特别是 CGRectMake
,它一直告诉我找不到符号。
文档说我需要导入 CoreGraphics:https://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CGGeometry/index.html#//apple_ref/c/func/CGRectMake
我的 CoreGraphics 的路径是 /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
;我怎样才能为这个功能找到合适的库?我是从 ctypes 做的。
顺便说一句,从阅读文档来看,它似乎只是 memset 一个 CGRect 并填充它的宽度、高度、x 和 y,这是真的吗? (在这种情况下我不需要费心去声明它,它是如此简单)。
您要么缺少导入,要么其他地方有很大的问题,导致编译器无法在上下文中看到它,或者有错字。
也就是说,CGRect 和 NSRect 在最后几个 OS X 版本中是相同的。在构建也将为 iOS 编译的代码时,您只需要使用 CGRect。
如果您想添加 CoreGraphics 框架,则:
1. Select Target
2. Build Phases
3. Link Binary With Libraries
4. +
5. CoreGraphics.framework
6. Add
最后我无法导出函数,所以我不得不使用的解决方案是自己定义函数,我猜它只是返回一个填充了字段的矩形并且它起作用了:)
CGRectMake: function() {
/* https://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CGGeometry/index.html#//apple_ref/c/func/CGRectMake
* CGRect CGRectMake (
* CGFloat x,
* CGFloat y,
* CGFloat width,
* CGFloat height
* );
*/
/******* does not work
return lib('CoreGraphics').declare('CGRectMake', self.TYPE.ABI,
self.TYPE.CGRect, // return
self.TYPE.CGFloat, // x
self.TYPE.CGFloat, // y
self.TYPE.CGFloat, // width
self.TYPE.CGFloat // height
);
*/
return function(x, y, width, height) {
return self.TYPE.CGRect(
self.TYPE.CGPoint(x, y),
self.TYPE.CGSize(width, height)
);
};
}
我正在尝试声明一些 CoreGraphics 函数,特别是 CGRectMake
,它一直告诉我找不到符号。
文档说我需要导入 CoreGraphics:https://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CGGeometry/index.html#//apple_ref/c/func/CGRectMake
我的 CoreGraphics 的路径是 /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
;我怎样才能为这个功能找到合适的库?我是从 ctypes 做的。
顺便说一句,从阅读文档来看,它似乎只是 memset 一个 CGRect 并填充它的宽度、高度、x 和 y,这是真的吗? (在这种情况下我不需要费心去声明它,它是如此简单)。
您要么缺少导入,要么其他地方有很大的问题,导致编译器无法在上下文中看到它,或者有错字。
也就是说,CGRect 和 NSRect 在最后几个 OS X 版本中是相同的。在构建也将为 iOS 编译的代码时,您只需要使用 CGRect。
如果您想添加 CoreGraphics 框架,则:
1. Select Target
2. Build Phases
3. Link Binary With Libraries
4. +
5. CoreGraphics.framework
6. Add
最后我无法导出函数,所以我不得不使用的解决方案是自己定义函数,我猜它只是返回一个填充了字段的矩形并且它起作用了:)
CGRectMake: function() {
/* https://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CGGeometry/index.html#//apple_ref/c/func/CGRectMake
* CGRect CGRectMake (
* CGFloat x,
* CGFloat y,
* CGFloat width,
* CGFloat height
* );
*/
/******* does not work
return lib('CoreGraphics').declare('CGRectMake', self.TYPE.ABI,
self.TYPE.CGRect, // return
self.TYPE.CGFloat, // x
self.TYPE.CGFloat, // y
self.TYPE.CGFloat, // width
self.TYPE.CGFloat // height
);
*/
return function(x, y, width, height) {
return self.TYPE.CGRect(
self.TYPE.CGPoint(x, y),
self.TYPE.CGSize(width, height)
);
};
}