我有一个按钮,通过界面构建器设置图像.原始图像是SearchImage.png,高rez版本是SearchImage@2x.png.我绝对相信没有拼写错误,而且分辨率较高的图像确实是较低分辨率图像的两倍大小(即两倍高,两倍宽),但办公室的iPhone4仍然只加载低分辨率图像.
有没有人有任何想法可能是什么问题?
我已阅读所有相关的Apple文档.
谢谢!特里斯坦
我想我已经找到了sizeWithFont的一个边缘情况:constrainedToSize:在视网膜显示器上,它有时(似乎基于自动换行)返回高于实际需要的高度1行,更重要的是它实际绘制的高度.
注意:我正在使用的真实代码被隐藏在高性能的中心手绘可变高度表视图单元代码中,因此我将问题简化为尽可能简单的示例代码.(当我试图回答我的问题以外的其他问题时请注意这一点:-)
这个示例UIView填充它的内容,测量文本以适合(包装),填充矩形,然后绘制文本.
在视网膜设备(或模拟器)上,高度返回1线太高,但在视网膜前设备(或模拟器)上返回正确的高度.
我非常感谢任何人可能拥有的任何洞察力,因为这是我想修复的错误!
非常感谢!
-Eric
- (void)drawRect:(CGRect)rect {
NSString * theString = @"Lorem ipsum dolor sit ameyyet, consectetur adipiscing elit. Etiam vel justo leo. Curabitur porta, elit vel.";
UIFont * theFont = [UIFont systemFontOfSize:12];
CGSize theConstraint = CGSizeMake(rect.size.width - 20, rect.size.height - 20);
CGSize theResultSize = [theString sizeWithFont:theFont constrainedToSize:theConstraint];
// dump the measurements
NSLog(@"returned a size h = %f, w = %f", theResultSize.height, theResultSize.width);
// fill the whole rect
CGContextRef context = UIGraphicsGetCurrentContext();
[[UIColor yellowColor] set];
CGContextFillRect(context, rect); …Run Code Online (Sandbox Code Playgroud) 我正在使用phonegap将一个非常简单的html5页面导出到iphone应用程序并遇到这个愚蠢的问题.
iPhone分辨率为960x640.
当我将画布设置为那些尺寸时,它似乎太大了.
<canvas width="960" height="580" style="background-color:#607559"></canvas>
Run Code Online (Sandbox Code Playgroud)
这是为什么?我怎样才能利用iphone4的全高清功能.如果我将画布设置为较旧的iPhone(320×480),似乎画布适合全屏.
将视口设置为这样的东西似乎有效,但这会对性能造成影响吗?
<meta name="viewport" content="width=device-width, height=device=height, initial-scale=0.5, maximum-scale=0.5, minimum-scale=0.5, user-scalable=no" />
Run Code Online (Sandbox Code Playgroud) 我即将将我的应用程序的最新版本上传到App Store,但是到目前为止我还没有在iOS 7上进行过大量的测试.
当我去使用模拟器时,我收到错误:
iPhone 4S不可用:请选择其他设备,然后重试.
我的部署目标已正确设置为7.0.
有没有人遇到过这个错误?有解决方案吗

我不完全了解Apple的iOS 4模型,我一直在仔细阅读文档几个小时,但我仍然感谢一些帮助.
背景的iPhone应用程序有没有退出?例如,当我关闭位置跟踪应用程序(例如Loopt)时,它将被后台化但是它是否会订阅操作系统的重要位置服务?根据苹果(如果我理解正确),即使它被暂停或关闭,它将被通知我当前的位置.这是否意味着,只要它在我的手机上,它总是会知道我的位置?或者直到我重新启动手机?
谢谢,
我有一些图像生成代码使用UIGraphicsBeginImageContext(),UIGraphicsGetImageFromCurrentImageContext()和UIImagePNGRepresentation()来做一些绘图,然后将其作为PNG保存到磁盘供以后使用.
UIImagePNGRepresentation()是否考虑了规模?如果我有一个20点宽的图像,那么得到的PNG是20像素还是40像素?
此外,当我显示这些图像时,我使用[UIImage imageWithContentsOfFile:]和[image drawInRect:].有没有办法提示这些方法使用更高分辨率的绘图?
我已经在这几天敲打了我的脑袋.
我想在CALayer(AVCaptureVideoPreviewLayer)上绘制一个矩形,恰好是iPhone4上摄像头的视频输入.
这是我设置的一部分;
//(in function for initialization)
-(void)initDevices {
AVCaptureDeviceInput *captureInput = [AVCaptureDeviceInput deviceInputWithDevice:[AVCaptureDevicedefaultDeviceWithMediaType:AVMediaTypeVideo] error:nil];
AVCaptureVideoDataOutput *captureOutput = [[AVCaptureVideoDataOutput alloc] init];
captureOutput.alwaysDiscardsLateVideoFrames = YES;
captureOutput.minFrameDuration = CMTimeMake(1, 30);
dispatch_queue_t queue;
queue = dispatch_queue_create("cameraQueue", NULL);
[captureOutput setSampleBufferDelegate:self queue:queue];
dispatch_release(queue);
NSString* key = (NSString*)kCVPixelBufferPixelFormatTypeKey;
NSNumber* value = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA];
NSDictionary* videoSettings = [NSDictionary dictionaryWithObject:value forKey:key];
[captureOutput setVideoSettings:videoSettings];
self.captureSession = [[AVCaptureSession alloc] init];
[self.captureSession addInput:captureInput];
[self.captureSession addOutput:captureOutput];
[self.captureSession setSessionPreset:AVCaptureSessionPresetHigh];
self.prevLayer = [AVCaptureVideoPreviewLayer layerWithSession: self.captureSession];
self.prevLayer.frame = CGRectMake(0, 0, 400, 400);
self.prevLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; …Run Code Online (Sandbox Code Playgroud) 我正在做一些简单的测试,将CALayer添加到UIView中.在我的iPhone 4应用程序的主控制器类中,我实现了viewDidLoad这样的方法:
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"%s", __PRETTY_FUNCTION__);
CALayer* ca = [[CALayer alloc] init];
[ca setBounds:self.view.bounds];
[ca setBackgroundColor:[[UIColor blueColor] CGColor]];
[self.view.layer addSublayer:ca];
}
Run Code Online (Sandbox Code Playgroud)
蓝色背景仅占屏幕的1/4.

我想知道是不是因为我没有考虑视网膜显示?在这种情况下,最佳做法是什么?
添加了以下调试消息:
NSLog(@"frame w:%f h:%f", self.view.frame.size.width, self.view.frame.size.height);
NSLog(@"bounds w:%f h:%f", self.view.bounds.size.width, self.view.bounds.size.height);
Run Code Online (Sandbox Code Playgroud)
输出:
frame w:320.000000 h:460.000000
bounds w:320.000000 h:460.000000
Run Code Online (Sandbox Code Playgroud) 属性"Latitude"是"LatitudeLongitude"类的标量类型.无法为其生成setter方法.
当我为托管对象生成代码时,我收到一条消息,我是否想要原始数据类型的标量属性.我应该用吗?我想让这个应用程序与iPhone 3 - 5兼容
这个问题有什么问题吗?
我正在将图像下载到我的应用程序,几周之后用户就不会关心了.我将它们下载到应用程序中,这样就不必每次发布都下载它们.问题是我不希望Documents文件夹变得比它随时间变大.所以我认为我可以"清理"超过一个月的文件.
问题是,那里会有一些文件会超过一个月,但我不想删除.它们将是静态命名文件,因此它们很容易识别,只有3或4个.虽然我想删除几十个旧文件.这是一个例子:
picture.jpg <--Older than a month DELETE
picture2.jpg <--NOT older than a month Do Not Delete
picture3.jpg <--Older than a month DELETE
picture4.jpg <--Older than a month DELETE
keepAtAllTimes.jpg <--Do not delete no matter how old
keepAtAllTimes2.jpg <--Do not delete no matter how old
keepAtAllTimes3.jpg <--Do not delete no matter how old
Run Code Online (Sandbox Code Playgroud)
我怎样才能有选择地删除这些文件?
提前致谢!
iphone-4 ×10
iphone ×5
ios ×4
xcode ×4
ios4 ×2
calayer ×1
camera ×1
canvas ×1
cocoa-touch ×1
cordova ×1
drawing ×1
html5 ×1
image ×1
nsobject ×1
objective-c ×1
properties ×1
resolution ×1
scalar ×1
sizewithfont ×1
uikit ×1
uiview ×1