Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios Axesdrawer Stanford cs193p像素和点_Ios_Objective C_Cs193p - Fatal编程技术网

Ios Axesdrawer Stanford cs193p像素和点

Ios Axesdrawer Stanford cs193p像素和点,ios,objective-c,cs193p,Ios,Objective C,Cs193p,我正在斯坦福大学(在iTunesU)学习CS 193p课程,我试图了解他们为Assignment 3提供的AxesDrawer类,特别是drawHashMarksInRect方法的这些行 #define HASH_MARK_SIZE 3 #define MIN_PIXELS_PER_HASHMARK 25 + (void)drawHashMarksInRect:(CGRect)bounds originAtPoint:(CGPoint)axisOrigin scale: (CGFloat)poi

我正在斯坦福大学(在iTunesU)学习CS 193p课程,我试图了解他们为Assignment 3提供的AxesDrawer类,特别是drawHashMarksInRect方法的这些行

#define HASH_MARK_SIZE 3
#define MIN_PIXELS_PER_HASHMARK 25
+ (void)drawHashMarksInRect:(CGRect)bounds originAtPoint:(CGPoint)axisOrigin scale: (CGFloat)pointsPerUnit
{
.....
int unitsPerHashmark = MIN_PIXELS_PER_HASHMARK * 2 / pointsPerUnit;
if (!unitsPerHashmark) unitsPerHashmark = 1;
CGFloat pixelsPerHashmark = pointsPerUnit * unitsPerHashmark;
....
}

他们怎么说使用像素而不使用contentScaleFactor属性?他们实际上是在使用像素还是仅仅是点,只是误用了这个术语?。在这里,学生们正确地将一个点视为一个点——这意味着你的bounds.size.width和bounds.size.height的尺寸与iPhone 3GS屏幕的像素尺寸相同

如果您正在编译附加的3Gs,则内容比例因子为1

如果您连接到iPhone 4或4s,则内容比例因子为2

但是AxesDrawer将scale视为pointsPerUnit,在iPhone4上是0.5,因此传递给它的scale是0.5

您可以通过将以下内容放置在图形视图的UIView类中来实现这一点:

CGFloat screenScale=self.contentScaleFactor;
CGFloat scaleForAxesDrawer=1/屏幕比例;
[[self.axes类]drawAxesInRect:graphArea原始点:axisPoint比例:scaleForAxesDrawer];
//其中graphArea是CGRect,axisPoint是CGPoint
比如说


AxesDrawer将在轴上至少每隔25个像素放置一个哈希标记和数字。

但contentScaleFactor是每个点的像素数。因此,在高分辨率的情况下,每个点将有更多的像素。但是,既然我们是在点范围内进行交易,那么系统不应该在不涉及我们的情况下自行处理吗?

您好,谢谢您的回答,但是您说“AxesDrawer将比例视为点运行它,iPhone 4上的比例是0.5,所以您传递给它的比例是0.5”,0.5将是像素而不是点,API文档说比例是以点而不是像素为单位的。