【发布时间】:2015-11-19 18:45:21
【问题描述】:
我们有一个案例,其中 4 台 iPad 中的 3 台按预期运行我们的应用程序,然后在没有在图表上加载大量 (x,y) 点数组的那台上,与屏幕截图的唯一区别是黑色背景导航中的“更新:阅读 rmaddy 关于常规 > 辅助功能中“按钮形状”设置的评论)
版本为 9.0.2(13A452),仅限 Wi-Fi,型号为 MD510LL/A
VS.
版本为 9.0.2(13A452),运营商为 Verizon 21.1,型号为 MD524LL/A
黑色按钮是运行 iOS 9 的第 4 代 iPad,并且该设备上只有老式黑色背景?我将 window.tintColor 更改为黑色以修复 UIAlertAction 错误,其中白色文本不可读,所以也许这可以解释部分原因?
图形问题
主要问题是在加载核心绘图图时,所有 x 值在时间间隔增量循环期间保持为零在一小部分设备上。我以前见过 32 位设备无法做到这一点,而第 4 代是 32 位的。但是...我个人已经测试了第四代 iPad,其规格与上述第二代相同。
在我的测试设备上一切正常...至于仅 Wi-Fi、Verizon/ATT 以及对这些问题的所有 32 位/64 位解释的差异,我发现这很有帮助:http://www.everymac.com/systems/apple/ipad/ipad-air-faq/differences-between-ipad-air-ipad-4th-gen.html
当 wifi 不可用时,iOS 9 中的某些新设置(例如“低功耗模式”)是否会影响使用 Verizon 数据计划进行联网的能力?这就是目前的情况,包括有问题的设备在 VPN 上。
同样,这是运行同一个应用程序的两种不同设备!黑色背景的设备在加载图表数据时出现问题。 iOS 9 中是否有新设置会导致设备之间出现这些奇怪的差异/错误?
注意:最近发现一位用户的 iPhone 6s+ 也有同样的图形错误,所以这不仅仅是 iPad 相关的......
以下是从 SOAP 响应对象填充 (x,y) 坐标的方式:
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"MM/dd/yyyy h:mm:ss a"];
if (unitCount == 0)
{
DataHistory_object *dho = [[DataHistory_object alloc] init];
dho.dataDate = [attributeDict objectForKey:@"Date"];
NSLog(@"dho.dataDate: %@",dho.dataDate);
dho.dataValue = [attributeDict objectForKey:@"Value"];
float dataValue = [dho.dataValue floatValue];
newDate = [dateFormat dateFromString:dho.dataDate];
[[NSUserDefaults standardUserDefaults] setObject:dho.dataDate forKey:@"firstDate"];
//@"start" is defined in a separate class
if (![[[NSUserDefaults standardUserDefaults] objectForKey:@"start"] isEqualToString:dho.dataDate])
{
NSDate *start = [dateFormat dateFromString:[[NSUserDefaults standardUserDefaults] objectForKey:@"start"]];
firstDate = [dateFormat dateFromString:dho.dataDate];
NSTimeInterval secondsBetween = [firstDate timeIntervalSinceDate:start];
interval = secondsBetween;
NSString *startDate = [NSString stringWithFormat:@"%@",[dateFormat stringFromDate:newDate]];
NSLog(@"firstDate: %@",startDate);
NSLog(@"unitCount == 0 if: %d - interval: %f",unitCount,interval);
}
else
{
NSLog(@"unitCount == 0 else: %d - interval: %f",unitCount,interval);
}
if (trendIndex == 0)
{
[dataHistoryArray addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:interval],@"x",[NSNumber numberWithFloat:dataValue],@"y",nil]];
}
if (trendIndex == 1)
{
[dataHistoryArray2 addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:interval],@"x",[NSNumber numberWithFloat:dataValue],@"y",nil]];
}
if (trendIndex == 2)
{
[dataHistoryArray3 addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:interval],@"x",[NSNumber numberWithFloat:dataValue],@"y",nil]];
}
if (trendIndex == 3)
{
[dataHistoryArray4 addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:interval],@"x",[NSNumber numberWithFloat:dataValue],@"y",nil]];
}
if (trendIndex == 4)
{
[dataHistoryArray5 addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:interval],@"x",[NSNumber numberWithFloat:dataValue],@"y",nil]];
}
if (trendIndex == 5)
{
[dataHistoryArray6 addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:interval],@"x",[NSNumber numberWithFloat:dataValue],@"y",nil]];
}
if (trendIndex == 6)
{
[dataHistoryArray7 addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:interval],@"x",[NSNumber numberWithFloat:dataValue],@"y",nil]];
}
oldDate = newDate;
unitCount++;
}
else
{
DataHistory_object *dho = [[DataHistory_object alloc] init];
dho.dataDate = [attributeDict objectForKey:@"Date"];
dho.dataValue = [attributeDict objectForKey:@"Value"];
float dataValue = [dho.dataValue floatValue];
newDate = [dateFormat dateFromString:dho.dataDate];
NSTimeInterval secondsBetween = [newDate timeIntervalSinceDate:oldDate];
interval = (interval + secondsBetween);
NSLog(@"unitCount %d - interval: %f",unitCount,interval);
if (trendIndex == 0)
{
[dataHistoryArray addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:interval],@"x",[NSNumber numberWithFloat:dataValue],@"y",nil]];
}
if (trendIndex == 1)
{
[dataHistoryArray2 addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:interval],@"x",[NSNumber numberWithFloat:dataValue],@"y",nil]];
}
if (trendIndex == 2)
{
[dataHistoryArray3 addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:interval],@"x",[NSNumber numberWithFloat:dataValue],@"y",nil]];
}
if (trendIndex == 3)
{
[dataHistoryArray4 addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:interval],@"x",[NSNumber numberWithFloat:dataValue],@"y",nil]];
}
if (trendIndex == 4)
{
[dataHistoryArray5 addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:interval],@"x",[NSNumber numberWithFloat:dataValue],@"y",nil]];
}
if (trendIndex == 5)
{
[dataHistoryArray6 addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:interval],@"x",[NSNumber numberWithFloat:dataValue],@"y",nil]];
}
if (trendIndex == 6)
{
[dataHistoryArray7 addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithFloat:interval],@"x",[NSNumber numberWithFloat:dataValue],@"y",nil]];
}
oldDate = newDate;
unitCount++;
}
数组的加载方式如下:
-(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot {
if ([(NSString *)plot.identifier isEqualToString:@"Blue"])
{
return [dataHistoryArray count];
}
//...same code for other arrays and colors
return 0;
}
-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index {
NSNumber *num;
if ([(NSString *)plot.identifier isEqualToString:@"Blue"])
{
num = [[dataHistoryArray objectAtIndex:index] valueForKey:(fieldEnum == CPTScatterPlotFieldX ? @"x" : @"y")];
return num;
}
//...same for other arrays and colors
return 0;
}
我还需要在添加每个绘图后操作图表:
-(void)changePlotRange {
y.orthogonalCoordinateDecimal = CPTDecimalFromFloat(appDelegate.lowY);
plotSpace = (CPTXYPlotSpace *)graph.defaultPlotSpace;
plotSpace.xRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(0.0f) length:CPTDecimalFromFloat([[NSUserDefaults standardUserDefaults] floatForKey:@"secondsBetween"])];
plotSpace.yRange = [CPTPlotRange plotRangeWithLocation:CPTDecimalFromFloat(appDelegate.lowY) length:CPTDecimalFromFloat(appDelegate.highY-appDelegate.lowY)];
}
【问题讨论】:
-
带有黑色按钮的设备已启用“设置”应用中“常规”->“辅助功能”下的“按钮形状”选项。这是在 iOS 7 中添加的。
-
@rmaddy 很棒的东西...这是一个艰难的谷歌,所以感谢 rmaddy 搜索引擎。数据丢失问题怎么办?刚刚得知他的 iPad 有充电问题并且可能有缺陷?在应用程序停止 SOAP 调用和/或创建 for 循环的大型字典之前,这会导致一定数量的处理发生吗?这是一个相关的 SO 帖子,其中包含关于 32 位与 64 位怪异的问答:stackoverflow.com/questions/31193731/…
-
这听起来像是数据加载方式的问题。它是通过网络下载的还是从 Core Data 等本地资源下载的?如果图表是在数据集可供应用程序使用之前绘制的,那么当新数据可用时,应用程序是否有回调或通知处理程序在图表上调用
-reloadData? -
@EricSkroch 它来自 Web 服务 SOAP 调用,是的,有多次调用 reloadData。这真的是关于为什么四分之三的用户没有遇到图形错误......即使我在用户的服务器上进行测试,我也无法重现错误,所以我开始认为它与日期有关由于时区和用户位置导致的格式错误,但我们最近才开始看到错误,iOS 9 所以....x 值与秒有关,所以如果循环将所有 x 值都设为“0”,则绘图在原点被“挤压”,但 y 值都是正确的。
-
你能发布你的数据加载和绘图代码吗?当我们看不到代码时,很难解决具体问题。