【发布时间】:2012-04-16 01:06:39
【问题描述】:
我在我的 iPhone 应用程序的多个地方的代码中使用了常量坐标,特别是当我以编程方式创建视图、设置 uiview 子类的属性时。
示例:
UIImage* img = [UIImage imageNamed:@"background.png"];
UIImageView *imgView = [[[UIImageView alloc] initWithImage: img] autorelease];
imgView.center = CGPointMake(160, 175); // --> Are these constant usages safe?
[self.view addSubview: imgView];
我已经在模拟器、3G 和 4S 设备上对其进行了测试,并且可以正常工作。 我应该担心未来的设备分辨率或任何其他问题吗? 如果是这样,我应该如何使这段代码更安全?这里有什么编码原则吗?
谢谢 兆赫
【问题讨论】:
标签: iphone objective-c xcode uiview