[英]How to implement NSArray method in IBAction?
I have been reading the code that was suggested to me in this thread here: How to get pixel data from a UIImage (Cocoa Touch) or CGImage (Core Graphics)? 我一直在这里阅读此线程中向我建议的代码: 如何从UIImage(Cocoa Touch)或CGImage(Core Graphics)获取像素数据?
I am wondering how I would implement the code in the following manner: 我想知道如何以以下方式实现代码:
-(IBAction)getRGB:(id)sender {
// Call getRGBAsFromImage here when pressed.
}
+ (NSArray*)getRGBAsFromImage:(UIImage*)image atX:(int)xx andY:(int)yy count:(int)count {
...
}
Thank you very much. 非常感谢你。
Edit for 0x90: 编辑为0x90:
-(IBAction)getRGB:(id)sender {
UIImage *image = [UIImage imageNamed:@"IMG_0121.JPG"];
[self getRGBAsFromImage:image atX:40 andY:40 count:40];
}
You would define a strong/retained (depends on whether you use ARC) property to store the returned NSArray
and then call the method as such: 您将定义一个强/保留(取决于是否使用ARC)属性来存储返回的NSArray
,然后这样调用该方法:
-(IBAction)getRGB:(id)sender {
propertyYouDefined = [self getRGBAsFromImage:image atX:42 andY:42 count:42];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.