在Xcode的Object Library中,有两个选项可用于创建表视图 - 表视图和表视图控制器.这两者之间有什么区别?何时使用它们?
我的LayoutConstraints工作正常,然后突然间我在向视图添加约束时开始得到这个.
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:]: Constraint must contain a first layout item'
*** First throw call stack:
(0x7cd012 0x2017e7e 0x7ccdeb 0xde6bf1 0x9c487 0x994a3 0x414fb 0x20224 0x5c6c0 0xc30e83 0x78c376 0x78be06 0x773a82 0x772f44 0x772e1b 0x28eb7e3 0x28eb668 0x149465c 0x2cfd 0x2c25)
libc++abi.dylib: terminate called throwing an exception
Run Code Online (Sandbox Code Playgroud)
互联网或Apple Docs上没有关于错误消息含义的直接文档.
只是想知道是否有人遇到过这个错误,并知道我可以做些什么来解决它?
在应用程序中,我绘制了一个弯曲的UIBezierPath和一个MKOverlayPathView类来显示航线.这是我正在使用的代码:
Run Code Online (Sandbox Code Playgroud)- (UIBezierPath *)pathForOverlayForMapRect:(MKMapRect)mapRect { ... bla bla bla ... UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:s]; [path addQuadCurveToPoint:e controlPoint:cp1]; [path addLineToPoint:e2]; [path addQuadCurveToPoint:s2 controlPoint:cp2]; [path closePath]; return path; }
- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context{
self.mapRect = mapRect;
CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
CGContextSetRGBStrokeColor(context, 0.0, 0.0, 0.0, 1.0);
CGContextSetLineWidth(context, mapRect.size.height/700);
CGContextSetLineJoin(context, kCGLineJoinRound);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextAddPath(context, [self pathForOverlayForMapRect:mapRect].CGPath);
[self updateTouchablePathForMapRect:mapRect];
CGContextDrawPath(context, kCGPathFillStroke);
}
Run Code Online (Sandbox Code Playgroud)
这工作得很好,但我想在该路径上绘制一个渐变,而不仅仅是填充颜色.这就是它开始变得非常棘手的地方.
我已经尝试过CGContextDrawLinearGradient(),但它还没有让我有用.
假设很久以前,我创建了以下枚举:
typedef enum
{
GeometricPoint,
GeometricLine,
GeometricSquare,
GeometricRectangle,
GeometricCircle
}GeometricFigures;
Run Code Online (Sandbox Code Playgroud)
我刚才在我令人敬畏的引擎中介绍了这些内容,现在我终于决定不再使用人GeometricSquare了,因为已经覆盖了GeometricRectangle.
首先,我可能会将枚举更改为以下内容:
typedef enum
{
GeometricPoint,
GeometricLine,
GeometricRectangle,
GeometricSquare = GeometricRectangle,
GeometricCircle
}GeometricFigures;
Run Code Online (Sandbox Code Playgroud)
这肯定会使我的真棒引擎向后兼容,但另一方面会增加传统垃圾.因此,我想GeometricSquare在可预见的将来完全删除.为了让我的引擎用户明白这一点,我想将其标记GeometricSquare为已弃用.
我的目标是文档(doxygen)以及代码完成(Xcode)以及最后但并非最不重要的编译器(GCC)将使用户明显GeometricSquare不再使用并且已被替换GeometricRectangle.
对于文档,我只想使用@deprecated关键字;
typedef enum
{
GeometricPoint,
GeometricLine,
GeometricRectangle,
///@deprecated Has been replaced by GeometricRectangle
GeometricSquare = GeometricRectangle,
GeometricCircle
}GeometricFigures;
Run Code Online (Sandbox Code Playgroud)
但Xcode和GCC怎么样?
不幸的是,通常的GCC(方法)属性似乎没有完成这项工作.添加 __attribute__((deprecated))如下所示会导致语法错误.
typedef enum
{
GeometricPoint,
GeometricLine,
GeometricRectangle,
GeometricSquare = GeometricRectangle __attribute__((deprecated)),
Run Code Online (Sandbox Code Playgroud)
Parse Issue Expected}
GeometricCircle
}GeometricFigures; …Run Code Online (Sandbox Code Playgroud) 在Xcode 6中,为不同大小的设备完成布局的方式已经有所改变:我们现在有了Size Classes.但是我如何为3.5英寸iPhone铺设界面呢?
"紧凑"高度等级似乎不适用于此.我知道我可以更改约束/压缩阻力(等)值,但在我的情况下,我希望能够更改此设备大小的字体大小.
这完全不可能吗?我意识到iOS 8不再支持iPhone 4(但不支持4S).我们也不能完全针对iOS 8,并且需要支持7甚至6.
我试图插入指明了AVPlayerItem的AVURLAsset AVPlayerItemStatusReadyToPlay成AVMutableComposition这样:
composition_ = [[AVMutableComposition alloc] init];
insertionPoint_ = kCMTimeZero;
item_ = [[AVPlayerItem playerItemWithURL:[NSURL URLWithString:@"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"]] retain];
[item_ addObserver:self forKeyPath:@"status" options:0 context:nil];
player_ = [[AVPlayer playerWithPlayerItem:item_] retain];
[player_ addObserver:self forKeyPath:@"currentItem.duration" options:0 context:nil];
/**
* append a player-item to our composition
*/
- (void)addItemToComposition:(AVPlayerItem *)item
{
NSError *error = nil;
VTRACE(@"item duration: %g", CMTimeGetSeconds(item.duration));
if (![composition_ insertTimeRange:CMTimeRangeMake(kCMTimeZero, item.duration)
ofAsset:item.asset
atTime:insertionPoint_
error:&error])
{
VTRACE(@"error: %@", error);
}
}
/**
* simplified value observer callback
*/
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary …Run Code Online (Sandbox Code Playgroud) 我希望能够在我的二进制文件内容列表中使用标准mime类型(或UTI类型)的内置iOS图标.
我已经研究过使用新的(自3.2)文档体系结构,但是使用UIDocumentInteractionController似乎假设实际的二进制文件已经在本地设备上了.
在我的情况下,我有一个远程服务器的文件列表,并知道远程文件的mime类型,名称,标题等,所以我只想显示带有图标的文件列表(实际二进制文件仅根据需要加载).
我从服务器获取的元数据包含二进制文件的正确mime类型,所以理论上我只想根据类型获取系统图标.
我尝试了以下"黑客"作为概念的证明,它似乎工作,但这似乎不是最好的方式...
//Need to initialize this way or the doc controller doesn't work
NSURL*fooUrl = [NSURL URLWithString:@"file://foot.dat"];
UIDocumentInteractionController* docController = [[UIDocumentInteractionController interactionControllerWithURL:fooUrl] retain];
UIImage* thumbnail = nil;
//Need to convert from mime type to a UTI to be able to get icons for the document
NSString *uti = [NSMakeCollectable(UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, (CFStringRef)self.contentType, NULL)) autorelease];
//Tell the doc controller what UTI type we want
docController.UTI = uti;
//The doc controller now seems to have icon(s) for the …Run Code Online (Sandbox Code Playgroud) 我不确定会发生什么,但当我尝试在Xcode中提交我的更改时,我得到了一个
致命:无法切换到'/ Users/charlesbutler/xCode/MA Mobile/MA MobileTests':没有这样的文件或目录
我有一堆像这样的文件.
有什么我可以做的,以消除他们的承诺.其中很多都被删除了(可能是我手动在项目文件夹中)
很多人都注意到了; zxing在最新的xcode中不起作用(4.5/ios 6)
这是用例:
- 从trunk查看最新版本(因为已经添加了一些修复)
- 使用ios 6.0在xcode 4.5中创建单个视图应用程序
- 使用README添加依赖项,路径等(只需按步骤操作)
- 添加zxingcontroller调用类(重命名为mm)
模拟器和设备的编译都失败它显示31错误,如下所示:
Undefined symbols for architecture i386:
"std::string::c_str() const", referenced from
Run Code Online (Sandbox Code Playgroud)
所有31个错误都是相似的,区别在于符号名称
可能有人知道如何用这个用例来解决它?
ps如果你有以前的Xcode的应用程序,它的工作原理.只有在Xcode 4.5中创建新应用程序时才会出现问题
我正在使用一个相当大的,资产密集的iOS项目,我不禁注意到Xcode复制了数百个资源(纹理,spritesheets,声音文件等),这些资源自上次以来一直没有变化我建立在设备上的时间.当每个构建在设备上弹出2-4分钟时,它使编码真的非常慢.
有没有办法让Xcode认识到它正在做多余的事情或编写一个脚本,使它能够更加智能地将资源转移到设备上?
PS我意识到应用程序可能没有任何内置的"附加"功能.我希望事实并非如此.
ios ×8
xcode ×4
objective-c ×3
iphone ×2
autolayout ×1
avfoundation ×1
avplayer ×1
bundle ×1
deprecated ×1
enums ×1
git ×1
gradient ×1
svn ×1
uibezierpath ×1
uikit ×1
uitableview ×1
zxing ×1