我必须使用s7graphview
库来绘制简单的直方图,并且我已经有了一个名为 -(IBAction)histogram:(id)sender;
的自定义函数。在这个函数中,图像中的每个像素都以RGB表示的形式传递给数组。然后计算像素,我有红色,绿色和蓝色的数组。我可以发送到NSLog或什么东西,但问题是,当我尝试发送3个阵列到- (NSArray *)graphView:(S7GraphView *)graphView yValuesForPlot:(NSUInteger)plotIndex;
。这两个函数都在同一个.m文件中,我不知道如何在它们之间传递数据,因为当我写入redArray时,Xcode不会建议我这个名字。如何在函数之间传递数据(数组)
0
A
回答
1
由于- (NSArray *)graphView:(S7GraphView *)graphView yValuesForPlot:(NSUInteger)plotIndex
是一个委托方法,所以应该在实施在您的班级冒充委托给S7GraphView
对象。你不显式调用,您在您的m执行它定义为这样的:
- (NSArray *)graphView:(S7GraphView *)graphView yValuesForPlot:(NSUInteger)plotIndex
{
if (plotIndex == <some index value>)
return redArray;
else
return nil;
}
我不知道什么plotIndex
对应与各种颜色的阵列,但你应该明白我的意思。
当S7GraphView
对象需要该数据时,它将调用该方法delegate
。
这与实施UITableViewDelegate
和UITableViewDataSource
方法不同。当调用一个UITableView
方法-reloadData
,它会呼吁您的视图控制器(假定它是表的委托/数据源)通过
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = <... dequeue or created ... >.
/*
do some cell set up code based on indexPath.section and indexPath.row
*/
return cell;
}
类似供应UITableViewCell
对象与S7GraphView
我相信(我不没有API可以看到它所做的一切)。在您的IBAction
方法中,您可能会做类似于:
- (IBAction)histogram:(id)sender
{
// maybe you recalculate your red, green, and blue component arrays here and cache
// or maybe you calculate them when requested by the delegate method
// tell the S7GraphView it needs to update
// (not sure what the reload method is actually called)
[self.myS7GraphView reloadGraph];
}
+0
感谢您的帮助 –
相关问题
- 1. 在函数之间传递数组C++
- 2. 在函数之间传递元数据
- 3. Python ctype - 如何在C函数之间传递数据
- 4. 如何在函数调用之间传递数据
- 5. 在子组件之间传递数据
- 6. 如何在ArrayLists之间传递数据?
- 7. 在函数之间传递参数
- 8. 如何传递C函数之间的指针数组?
- 9. 组件之间的数据传递Angular4
- 10. 如何查看之间传递数据
- 11. 每个函数之间传递参数
- 12. 传递数据之间
- 13. 在嵌套函数之间传递数组()
- 14. 在两个函数之间传递数组值
- 15. VC++:在函数之间传递多个数组
- 16. 使用struct在函数之间传递数组信息
- 17. 如何在数据线程之间传递数据?
- 18. 如何在活动之间保存数据并传递数据
- 19. 如何在函数之间传递此数字? C
- 20. 如何在组件之间传递大量数据
- 21. 向jQuery函数传递数据数组
- 22. 在C++函数之间传递C#类
- 23. 在函数之间传递结构C++
- 24. 在JavaScript函数之间传递Json值
- 25. 在函数之间传递变量
- 26. 在函数之间传递变量
- 27. 在函数之间传递boost :: bimap
- 28. Python:在函数之间传递变量
- 29. VBA - 在函数之间传递对象
- 30. python - 在函数之间传递变量
Xcode并不总是提示您(正确)。如果这是你自己的功能,你可以添加更多的参数来传递更多的数据。 (顺便说一下,你的帖子实际上是无法理解的 - 你的问题最好还是不清楚。) –
' - (NSArray *)graphView:(S7GraphView *)graphView yValuesForPlot:(NSUInteger)plotIndex;'不是我的函数。它是委托功能。 –
您需要找到一种方法来允许该委托方法查看您的三个数组。你有没有尝试将你的三个数组放入ivars并从那个graphView委托方法中访问它们? –