在更新到Mavericks并确保我安装了最新的Xcode更新后,Xcode突然无法在设备上启动应用程序.
它在我的iPhone上安装应用程序,但在运行之前,抛出此错误:
进程启动失败:无法获得进程216的任务
这是自更新以来代码签名设置的样子:
还检查了Scheme,它在Debug配置中运行.
这是小牛队的一个已知问题吗?怎么解决?
我遇到了一个声明为C函数的例子:
static inline CGPoint SOCGPointAdd(const CGPoint a, const CGPoint b) {
return CGPointMake(a.x + b.x, a.y + b.y);
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,我在.h文件中声明了实用程序C函数并在.m文件中实现它们,就像这样:
CGPoint SOCGPointAdd(const CGPoint a, const CGPoint b) {
return CGPointMake(a.x + b.x, a.y + b.y);
}
Run Code Online (Sandbox Code Playgroud)
我可以在任何我想要的地方"内联"使用这个函数,它也应该是"静态的",因为它不与任何对象相关联,比如Objective-c方法.指定"静态"和"内联"的重点是什么?
在iOS 8下调用UIView的
[self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES];
Run Code Online (Sandbox Code Playgroud)
导致图像的1帧闪烁.你可以在屏幕上看到它一瞬间.它仅在afterScreenUpdates参数为YES时发生.
这是我拍摄截图的完整代码:
UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, sf);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSaveGState(ctx);
CGContextConcatCTM(ctx, [self.layer affineTransform]);
if ([self respondsToSelector:@selector(drawViewHierarchyInRect:afterScreenUpdates:)]) { // iOS 7+
[self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES];
} else { // iOS 6
[self.layer renderInContext:ctx];
}
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
CGContextRestoreGState(ctx);
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)
有解决方法吗?
我正面临一个奇怪的问题,只有一个横向应用程序.它可以向左或向右旋转,但是当应用程序启动时,它会旋转180度而不是以正确的方向启动.
我在StackOverflow和Google上做了我能找到的一切.信息plist包含:
经过测试:iOS 7.1完全忽略了plist中的初始启动方向设置.我左右尝试,然后从信息plist中删除了密钥.没有效果.应用程序始终使用左侧的主页按钮启动横向,忽略此设置.
重试时,我删除应用程序并清理构建.
在App Delegate中,我有:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
- (BOOL)shouldAutorotate {
return YES;
}
Run Code Online (Sandbox Code Playgroud)
在根视图控制器中:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight;
}
- (BOOL)shouldAutorotate {
return YES;
}
Run Code Online (Sandbox Code Playgroud)
像Tiny Wings这样的一些风景应用程序以正确的方向启动,所以我知道我的项目有问题.让这个工作的秘诀是什么?
试图画一条三角形,如下图所示:
完成了objc.io 教程,他们使用两个三角形绘制四边形.三角形是断开连接并单独绘制的,这意味着我需要指定6个顶点而不是4个顶点.
// Interleaved vertex data X,Y,Z,W, R,G,B,A
static float vertexData[] = {
// First triangle: From bottom right, clockwise
0.5, -0.5, 0.0, 1.0, 1.0, 0.0, 0.0, 1.0, // bottom right
-0.5, -0.5, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, // bottom left
-0.5, 0.5, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, // top left
// Second triangle: From top right, clockwise
0.5, 0.5, 0.0, 1.0, 1.0, 1.0, 0.0, 1.0, // top right
0.5, -0.5, 0.0, 1.0, 1.0, 0.0, 0.0, …
Run Code Online (Sandbox Code Playgroud) 此代码将图像和灰度蒙版图像组合成一个UIImage.它有效,但很慢.
+ (UIImage*) maskImage:(UIImage *)image withMask:(UIImage *) mask
{
CGImageRef imageReference = image.CGImage;
CGImageRef maskReference = mask.CGImage;
CGImageRef imageMask = CGImageMaskCreate(CGImageGetWidth(maskReference),
CGImageGetHeight(maskReference),
CGImageGetBitsPerComponent(maskReference),
CGImageGetBitsPerPixel(maskReference),
CGImageGetBytesPerRow(maskReference),
CGImageGetDataProvider(maskReference),
NULL, // Decode is null
YES // Should interpolate
);
CGImageRef maskedReference = CGImageCreateWithMask(imageReference, imageMask);
CGImageRelease(imageMask);
UIImage *maskedImage = [UIImage imageWithCGImage:maskedReference];
CGImageRelease(maskedReference);
return maskedImage;
}
Run Code Online (Sandbox Code Playgroud)
我认为Accelerate Framework可以提供帮助.但我不确定.有vImage,它可以做alpha合成.或者也许我想要的是" vImage变换 ".不像CATransform3D而是"转换"图像.
但我需要的是将照片制作成基于蒙版的透明JPEG.
可以使用Accelerate Framework吗?还是有替代方案吗?
最后,我将Xcode 5的资产目录用于应用程序图标.
该应用程序支持iOS 6及更高版本.剩下的拼图是:是否仍然需要包含CFBundleIcons密钥?文件名是否重要?
Apple整理了这份文件,其中讨论了包含CFBundleIcons密钥.我很困惑,因为我没有看到资产目录的优势是什么.
我的应用程序开发人员的一些提示:
应用程序图标资产目录中的某些图标具有相同的大小.您可以重复使用图标.默认情况下,Xcode会复制它们.当您将图标从Finder拖到第二个占位符时,Xcode将创建一个图标的大量副本.它增加了一个-1
名字.如果要为两个占位符重复使用图标,请右键单击"Images.xcassets"选项卡下左侧的"AppIcon"资产目录项,然后选择"在Finder中显示".您将看到一个AppIcon.appiconset
包含Contents.json
文件的文件夹.在文本编辑器(如Sublime Text或Smultron)中打开此文件,搜索复制图标的文件名,并重命名该条目以匹配原始名称.然后删除重复的图标.
要显示资产目录,请单击Project Navigator顶部的项目文件.选择目标.向下滚动到"App Icons"部分.单击右侧的箭头.
要删除iOS添加的光泽效果,请选择左侧的"AppIcon"资产目录.然后揭示检查员.单击Xcode中的右上角图标以显示右侧面板.然后单击最右侧的图标以查看属性检查器.选中"iOS图标已预渲染".
只有内部Ad Hoc分发的企业应用程序才需要没有扩展名的胖512x512和1024x1024 iTunesArtwork文件.App Store应用程序不需要此功能.
我对3D图形非常感兴趣,并听到许多开发人员对Metal赞不绝口.
可以使用Metal和OpenGL ES 2.0的人评论学习曲线与OpenGL ES 2.0的比较吗?
作为一个致力于保持对iOS忠诚度的初学者,Metal比OpenGL ES 2.0更容易学习和掌握,还是因为它更先进而更难?
我希望这个问题对许多人有用,因为我想弄清楚从哪里开始.
我们正在制作一个应用程序,用于收集Health应用程序中列表不支持的特殊类型的数据.有没有办法为此创建一个新类别?
例如,如果您创建自己的GCD队列:
self.renderQueue = dispatch_queue_create("com.test.queue", DISPATCH_QUEUE_SERIAL);
Run Code Online (Sandbox Code Playgroud)
您是否必须在提交到该队列的每个块中创建自动释放池,使用:
@autoreleasepool {
}
Run Code Online (Sandbox Code Playgroud)
?
或者ARC是否为您创建了它?如果您未在自定义队列中指定autoreleasepool,会发生什么?
jQuery 1.11.1,在Mac OS X Mavericks上,最新版本的Safari.
我正在尝试使用css函数设置CSS属性.元素中缺少css().
首先,我验证了元素是否正确选择:
// There is only one element that has id="container"
var $container = $('#container');
// Selector returns a collection. I have to access first element:
console.log($container[0]); // prints HTMLDivElement
// css function is undefined
console.log($container[0].css); // prints undefined
// Also can't set any css value. Gives undefined error.
$container[0].css({backgroundColor:'blue'});
Run Code Online (Sandbox Code Playgroud)
错误是:
TypeError:'undefined'不是函数(评估'$ container [0] .css({backgroundColor:'blue'})')
我从测试页面中删除了所有内容.它包含jQuery,并且在体内它具有带ID的div.非常简单.在其下方,有上面显示的JavaScript代码.
知道为什么div会缺少css功能吗?
该文件说:
通过ad-hoc分发分发的应用程序还可以在CFBundleIcons密钥中包含其图标的512 x 512像素版本.此文件的名称必须是iTunesArtwork,并且没有文件扩展名.此图标的高分辨率版本应为1024 x 1024像素,并且名称为iTunesArtwork @ 2x.如果您没有通过ad-hoc分发分发您的应用,请不要在您的应用包中包含此图标.
我感到困惑,因为我一直认为Apple拒绝不包含此文件的应用程序.在iTunes中,您会看到一个非常大的应用程序图标.它必须是这个文件.或不?所以无论这个文件说什么,它都应该包含在捆绑包中?
例如,如果您具有类型UIUserNotificationType的位掩码,并按如下方式构造它们:
UIUserNotificationType a = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge;
UIUserNotificationType b = UIUserNotificationTypeAlert;
UIUserNotificationType c = UIUserNotificationTypeAlert | UIUserNotificationTypeSound;
Run Code Online (Sandbox Code Playgroud)
如何将一个字段与另一个字段匹配,以查看所有字段都包含在另一个字段中?
b
已完全包含在其中,a
且结果应为TRUE。
c
未完全包含在其中a
,应导致FALSE。
我知道如何测试一个特定字段的成员资格:BOOL match =(b&UIUserNotificationTypeAlert)!= 0;
这不起作用:
BOOL included = (a & b); // a includes b? (= YES)
included = (a & c); // a includes c? (= YES)
Run Code Online (Sandbox Code Playgroud)
要知道一个位掩码的所有字段是否都包含在另一个字段中,我必须if
为每个可能的字段创建一个,然后像这样对它进行测试:
if (b & UIUserNotificationTypeAlert && !(a & UIUserNotificationTypeAlert)) {
return NO;
}
if (b & UIUserNotificationTypeBadge && !(a & UIUserNotificationTypeBadge)) {
return NO; …
Run Code Online (Sandbox Code Playgroud)