我正在使用核心图库绘制图形。对于某些动画,我必须拍摄整个屏幕的图像快照以使其平滑。问题是当我尝试从图表中获取图像时。该图总是上下颠倒。如果我仅将图形本身作为快照,那么这将不是问题-我可以轻松地对其进行转换。问题是,我正在对整个屏幕进行动画处理,以便拍摄整个UIWindow的快照,该UIWindow在其子视图之一中包含图形。我使用code.google上coreplot项目中提供的coreplot 0.2.2示例进行了尝试。我只是向窗口添加了一个按钮(以便在每个选项卡上可见),当按下按钮时,我从窗口内容中获取图像,并使用以下代码将其另存为相册库中的图像:
UIView *window = [[UIApplication sharedApplication] keyWindow];
UIGraphicsBeginImageContext(window.frame.size);
[window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(newImage, nil, NULL, NULL);
Run Code Online (Sandbox Code Playgroud)
结果如上所述。与屏幕上可见的图形相比,生成的图像中的图形颠倒显示。我做错了还是那是核心漏洞?
我正在尝试将CorePlot合并到我的项目中.我终于设法识别我的头文件但我在main.m中不断收到以下错误.
"'''令牌之前的预期表达"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([ProjectFiveAppDelegate class]));
}
}
Run Code Online (Sandbox Code Playgroud) 为什么Core Plot绘制这两行?

这就是我设置图表的方式:
// setup the pie chart
graph = [[CPTXYGraph alloc] initWithFrame:[_pieView bounds]];
[_pieView setHostedGraph:graph];
CPTPieChart *pieChart = [[CPTPieChart alloc] init];
[pieChart setDataSource:self];
[pieChart setPieRadius:75.0];
[pieChart setIdentifier:@"PieChart1"];
[pieChart setStartAngle:M_PI_4];
[pieChart setSliceDirection:CPTPieDirectionClockwise];
[graph addPlot:pieChart];
Run Code Online (Sandbox Code Playgroud)
(_pieView是CPTGraphHostingView*)
如何删除两条黑线?我尝试过如何删除核心图表周围的边框,但无济于事.
有什么方法可以让Core Plot滚动在UIScrollView中表现得像动量滚动一样吗?我制作了一个CPTGraphHostingView并将其作为子视图添加到UIViewController.view中.
有人会善意提供方向或代码来指导我完成吗?
我是Core Plot的新手,我无法在我的视图中添加一个Legend.我一直在尝试各种教程并阅读大量信息,但我不明白如何显示图例.
我真的很感激一些帮助,因为我花了很多时间试图让它发挥作用.
请注意,我在这一点上的目标是显示如下传奇:

这是我得到的:

唯一出现的是右边的粗线.我可以移动,但不能得到传说.
代码:
// Create pieChart from theme
pieChart = [[CPTXYGraph alloc] initWithFrame:CGRectZero];
CPTTheme *theme = [CPTTheme themeNamed:kCPTDarkGradientTheme];
[pieChart applyTheme:theme];
//Create host view
self.hostingView = [[CPTGraphHostingView alloc]
initWithFrame:[[UIScreen mainScreen]bounds]];
[self.view addSubview:self.hostingView];
hostingView_.hostedGraph = pieChart;
pieChart.axisSet = nil;
pieChart.plotAreaFrame.borderLineStyle = nil;
pieChart.paddingLeft = 10.0;
pieChart.paddingTop = 120.0;
pieChart.paddingRight = 10.0;
pieChart.paddingBottom = 80.0;
pieChart.fill = [CPTFill fillWithColor:[CPTColor clearColor]];
pieChart.plotAreaFrame.fill = [CPTFill fillWithColor:[CPTColor clearColor]];
CPTMutableTextStyle *whiteText = [CPTMutableTextStyle textStyle];
whiteText.color = [CPTColor whiteColor];
whiteText.fontSize = 14;
whiteText.fontName = …Run Code Online (Sandbox Code Playgroud) 我是iPhone开发新手.对iPhone技术中的视图和布局不太熟悉.
我想要实现的是:
这可能吗 ?
任何帮助将不胜感激.
我正在使用Core Plot(1.1)来绘制一个条形图,我想在条形图下方提供一个popover,其中有更多细节由用户选择(点击).
我的代码看起来像这样:
- (void)barPlot:(CPTBarPlot *)plot barWasSelectedAtRecordIndex:(NSUInteger)idx {
NSNumber *yValue = self.values[idx];
NSLog(@"barWasSelectedAtRecordIndex x: %i, y: %@",idx,yValue);
NSDecimal plotPoint[2];
NSNumber *plotXvalue = [self numberForPlot:plot
field:CPTScatterPlotFieldX
recordIndex:idx];
plotPoint[CPTCoordinateX] =
CPTDecimalFromFloat(plotXvalue.floatValue);
NSNumber *plotYvalue = [self numberForPlot:plot
field:CPTScatterPlotFieldY
recordIndex:idx];
plotPoint[CPTCoordinateY] =
CPTDecimalFromFloat(plotYvalue.floatValue);
CPTXYPlotSpace *plotSpace =
(CPTXYPlotSpace *)graph.defaultPlotSpace;
CGPoint dataPoint =
[plotSpace plotAreaViewPointForPlotPoint:plotPoint];
NSLog(@"datapoint (CGPoint) coordinates tapped: %@",
NSStringFromCGPoint(dataPoint));
GrowthChartInfoTableViewController *infoViewController =
[self.storyboard instantiateViewControllerWithIdentifier:
@"GrowthChartInfo"];
self.popover = [[UIPopoverController alloc]
initWithContentViewController:infoViewController];
self.popover.popoverContentSize = CGSizeMake(320, 300);
self.popover.delegate = self;
CGRect popoverAnchor =
CGRectMake(dataPoint.x + …Run Code Online (Sandbox Code Playgroud) 当我在y轴上只显示一个间隔时,我想在屏幕上看到x轴.当间隔从0显示时,x轴是可见的,所以我认为我应该使用yRange向上移动x轴,但我不确切知道如何做到这一点.
这是我设置xRange和yRange的部分.对于y轴,我搜索我想要显示的最小值和最大值.
CPTMutablePlotRange *xRange = [plotSpace.xRange mutableCopy];
[xRange expandRangeByFactor:CPTDecimalFromCGFloat(1.1f)];
plotSpace.xRange = xRange;
//CPTMutablePlotRange *yRange = [plotSpace.yRange mutableCopy];
//[yRange expandRangeByFactor:CPTDecimalFromCGFloat(1.2f)];
//plotSpace.yRange = yRange;
cpd = [CPDStockPriceStore sharedInstance];
NSMutableArray *arr = cpd.prices;
minY = 10000;
maxY = 0;
for (unsigned i = 1; i < [arr count]; i++){
if([[arr objectAtIndex:i] intValue] < minY) minY = [[arr objectAtIndex:i]intValue];
if([[arr objectAtIndex:i] intValue] > maxY) maxY = [[arr objectAtIndex:i]intValue];
}
CGFloat yMin = 100*((minY-200)/100);
CGFloat yMax = 100*((maxY+200)/100); // should determine dynamically based on max …Run Code Online (Sandbox Code Playgroud) 我有一个iOS7应用程序,我试图将CorePlot 1.4集成到(从属项目安装).
@property (nonatomic) CPTGraphHostingView *hostingView;
Run Code Online (Sandbox Code Playgroud)
和
_hostingView = [[CPTGraphHostingView alloc] initWithFrame:CGRectNull];
Run Code Online (Sandbox Code Playgroud)
(_hostingView受自动布局限制.)如果我然后添加图表:
CPTXYGraph *graph = [[CPTXYGraph alloc] initWithFrame:CGRectZero];
_hostingView.hostedGraph = graph;
Run Code Online (Sandbox Code Playgroud)
我首先得到这个例外:
-[CPTTextStyle attributes]: unrecognized selector sent to instance 0xa392900
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CPTTextStyle attributes]: unrecognized selector sent to instance 0xa392900'
5 myapp 0x00074325 -[CPTAxis updateAxisLabelsAtLocations:inRange:useMajorAxisLabels:] + 1141
6 myapp 0x00075662 -[CPTAxis relabel] + 1202
Run Code Online (Sandbox Code Playgroud)
无奈之下,我已经updateAxisLabelsAtLocations:inRange:useMajorAxisLabels通过以下方式解决了这个问题:
NSDictionary *textAttributes = nil;
BOOL hasAttributedFormatter = FALSE;
Run Code Online (Sandbox Code Playgroud)
然后得到下一个异常:
-[__NSCFString sizeWithTextStyle:]: unrecognized selector …Run Code Online (Sandbox Code Playgroud) 我刚刚安装了Xcode 5.1,发现它肯定需要项目使用ARC.我明白了
error: garbage collection is no longer supported
Run Code Online (Sandbox Code Playgroud)
在尝试编译Core Plot(版本1.4)时.出于好奇,我告诉Xcode将Core Plot转换为ARC.但它失败了
ARC forbids Objective-C objects in struct
Run Code Online (Sandbox Code Playgroud)
在文件中CPTPlatformSpecificFunctions.m.我不想潜入Core Plot并试图解决这个或类似的错误.是否有我忽略的编译器设置?或者是否会有很快使用ARC的Core Plot版本?谢谢,德克
core-plot ×10
ios ×4
iphone ×3
objective-c ×3
axis-labels ×1
expression ×1
graph ×1
ios7 ×1
pie-chart ×1
plot ×1
screenshot ×1
scroll ×1
uiscrollview ×1
uiview ×1
xcode ×1
xcode5 ×1
xcode5.1 ×1