我尝试了以下两种方法来附加UIImage
s pixelbuffer ASSETWriterInput
.除了视频文件中没有数据外,一切看起来都不错.怎么了?
AVAssetWriterInputPixelBufferAdaptor * avAdaptor = [AVAssetWriterInputPixelBufferAdaptor assetWriterInputPixelBufferAdaptorWithAssetWriterInput:writerInput sourcePixelBufferAttributes:NULL];
[avAdaptor appendPixelBufferixelBuffer withPresentationTime:CMTimeMake(1, 10)];
Run Code Online (Sandbox Code Playgroud)
// Create sample buffer.
CMSampleBufferRef sampleBuffer = NULL;
result = CMSampleBufferCreateForImageBuffer(kCFAllocatorDef ault, pixelBuffer, true, NULL, NULL, videoInfo, &timing, &sampleBuffer);
// Ship out the frame.
NSParameterAssert(CMSampleBufferDataIsReady(sample Buffer));
NSParameterAssert([writerInput isReadyForMoreMediaData]);
BOOL success = [writerInput appendSampleBuffer:sampleBuffer];
Run Code Online (Sandbox Code Playgroud) 我一直在学习很多关于ReactiveCocoa的知识,但还有一件事让我感到困惑:为什么信号块会自动RACCommand
返回信号?
我理解RACCommand
它的canExecute
信号和信号块的用例,以及如何将它连接到UI元素.但是,返回其他东西会有什么情况[RACSignal empty]
呢?
infoButton.rac_command = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(id input) {
// Do stuff
return [RACSignal empty];
}];
Run Code Online (Sandbox Code Playgroud) 我试图让我的应用程序(在Dock中没有出现)可以选择在登录时启动.这很棘手,并且涉及创建第二个辅助应用程序,您将其添加为启动项.此帮助应用程序仅负责启动主应用程序然后退出.
我按照这里和 这里的说明进行操作,它就像一个魅力 - 问题当然是代码签名.我有两个目标; 辅助应用程序目标Contents/Library/LoginItems
在编译时被复制到主包的子目录中.每个捆绑包都有自己的捆绑包标识符和自己的部署配置文件,但是当我为应用商店验证我的归档时,我收到以下错误:
Invalid provisioning profile. The provisioning profile included in the bundle BUNDLE NAME [BUNDLE NAME.app] is invalid. For more information, visit the Mac OS Developer Portal.
Run Code Online (Sandbox Code Playgroud)
如果我从主目标中删除辅助包,则没有问题.看起来另一个配置文件的存在正在引发错误.
如何包含两个已签名的包并通过验证?
在ReactiveCocoa中,subscribeError:
方法与catch:
?之间的区别是什么?你为什么要回信号catch:
?
所以我在Crashlytics中经常看到这种崩溃,在iPad和iPad 2上运行iOS 5.看起来它是由内存警告引起的,但是堆栈跟踪没有引用我的任何应用程序代码,只是iOS构架:
0 libobjc.A.dylib objc_msgSend + 15
1 UIKit -[UIViewController purgeMemoryForReason:] + 64
2 Foundation __57-[NSNotificationCenter addObserver: selector: name: object:]_block_invoke_0 + 18
3 CoreFoundation ___CFXNotificationPost_block_invoke_0 + 70
4 CoreFoundation _CFXNotificationPost + 1406
5 Foundation -[NSNotificationCenter postNotificationName: object: userInfo:] + 66
6 Foundation -[NSNotificationCenter postNotificationName: object:] + 30
7 UIKit -[UIApplication _performMemoryWarning] + 80
8 UIKit -[UIApplication _receivedMemoryNotification] + 174
9 libdispatch.dylib _dispatch_source_invoke + 516
10 libdispatch.dylib _dispatch_queue_invoke + 50
11 libdispatch.dylib _dispatch_main_queue_callback_4CF + 156
12 CoreFoundation __CFRunLoopRun + 1268 …
Run Code Online (Sandbox Code Playgroud) 我是Node.js,Mongoose的新手,并且在这个环境中进行测试.我在单独的文件中声明了以下架构.
Issue = mongoose.model("Issue", {
identifier: String,
date: String,
url: String,
name: String,
thumbnailURL: String
});
Run Code Online (Sandbox Code Playgroud)
然后我有这个方法,只返回Issue
MongoDB集合中的所有实例.
function issues(request, response) {
response.setHeader('Content-Type', 'text/json');
Issue.find().sort('date').exec(function(error, items) {
if (error) {
response.send(403, {"status": "error", "error:": exception});
}
else {
response.send(200, {"issues": items});
}
});
}
Run Code Online (Sandbox Code Playgroud)
我已经通过实验得到了这一点,现在我想测试它,但我遇到了一个问题.如何在不设置MongoDB连接的情况下进行测试,我知道我可以设置所有这些内容,但这是一个集成测试.我想编写单元测试来测试以下内容:
date
字段排序我很想知道如何重构我现有的代码以使其更具单元可测试性.我尝试过创建第二个被调用的函数,接受response
和Item
架构对象作为参数,但感觉不对.有谁有更好的建议?
我正在写一个自定义UICollectionViewFlowLayout
,我注意到了,当我在集合视图上调用时initialLayoutAttributesForAppearingItemAtIndexPath:
,initialLayoutAttributesForAppearingDecorationElementOfKind:atIndexPath:
将调用所有部分performBatchUpdates:completion:
.结果是所有部分都应用了动画,而不仅仅是新添加的部分.
[collectionView performBatchUpdates:^{
currentModelArrayIndex++;
[collectionView insertSections:[NSIndexSet indexSetWithIndex:currentModelArrayIndex]];
[collectionView reloadSections:[NSIndexSet indexSetWithIndex:currentModelArrayIndex-1]];
} completion:^(BOOL finished) {
[collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:currentModelArrayIndex] atScrollPosition:UICollectionViewScrollPositionTop animated:YES];
}];
Run Code Online (Sandbox Code Playgroud)
我到目前为止所尝试的是删除调用而performBatchUpdates:completion:
不是简单的更新,但是已经存在的部分(所有部分)都是动画的.我想出了一个检查的解决方案,以确保我只更改了最后一节的布局属性,但它感觉很hacky.
if (decorationIndexPath.section == [(id<UICollectionViewDataSource>)self.collectionView.delegate numberOfSectionsInCollectionView:self.collectionView] - 1)
{
layoutAttributes.alpha = 0.0f;
layoutAttributes.transform3D = CATransform3DMakeTranslation(-CGRectGetWidth(layoutAttributes.frame), 0, 0);
}
Run Code Online (Sandbox Code Playgroud)
这是仅仅为某些部分制作动画的正确方法吗?
objective-c uikit ios6 uicollectionview uicollectionviewlayout
我有一个CAGradientLayer我用作阴影.它从60%不透明度变为清晰,从左到右.在渐变的边缘,它似乎与其下面的图层混合并使该图层变亮:
在阴影的最末端有一个像素宽的"发光",它在那里消失得很清晰.它似乎使阴影背后的阴影照片更亮.这是一个特写:
这是产生阴影的代码:
CAGradientLayer *layer = [CAGradientLayer layer];
layer.frame = CGRectMake(sideBar.frame.size.width, 0, 7, sideBar.frame.size.height);
layer.colors = [NSArray arrayWithObjects:
(id)[[[UIColor blackColor] colorWithAlphaComponent:0.6f] CGColor],
(id)[[UIColor clearColor] CGColor],
nil];
[layer setStartPoint:CGPointMake(0, 0.5)];
[layer setEndPoint:CGPointMake(1, 0.5)];
[sideBar.layer insertSublayer:layer atIndex:0];
sideBar.layer.masksToBounds = NO;
Run Code Online (Sandbox Code Playgroud)
关于如何摆脱它的任何想法?
我有一个问题,我已经工作了几个星期.每当我保存我的Core Data托管对象上下文时,它都会导致UI性能出现问题.我已经尽我所能并且正在寻找一些帮助.
我的应用程序使用两个NSManagedObjectContext
实例 一个属于应用程序委托,并且附加了持久性存储协调器.另一个是主要MOC的一个孩子,属于一个Class
叫做的对象PhotoFetcher
.它使用,NSPrivateQueueConcurrencyType
因此在此MOC上执行的所有操作都在后台队列中进行.
我们的应用程序从我们的API下载表示有关照片数据的JSON数据.为了从API检索数据,执行以下步骤:
NSURLRequest
对象并使用该NSURLConnectionDataDelegate
协议构造从请求返回的数据,或处理错误.NSJSONSerialization
基础类实例解析JSON .SQLite
商店.最后,向委托进行回调,通知他们响应已完全插入到Core Data存储中.保存背景MOC的代码如下所示:
[AppDelegate.managedObjectContext performBlock:^{
[AppDelegate saveContext]; //A standard save: call to the main MOC
}];
Run Code Online (Sandbox Code Playgroud)
当主对象上下文保存时,它还保存了自上次发生主对象上下文保存以来已下载的相当数量的JPEG.目前,在iPhone 4上,我们正在以70%的压缩率下载15个200x200 JPEG,或者总共下载大约2MB的数据.
这很有效,效果很好.我的问题是,一旦后台上下文保存,NSFetchedResultsController
我的视图控制器中的运行将获取传播到主MOC的更改.它在我们PSTCollectionView
的开源克隆中插入新细胞UICollectionView
.在插入新单元格时,主上下文会将这些更改保存并写入磁盘.在运行iOS 5.1的iPhone 4上,这可以在250-350ms之间.
在三分之一秒内,该应用程序完全没有响应.暂停之前正在进行的动画暂停,并且在保存完成之前,没有新的用户事件发送到主运行循环.
我使用Time Profiler在Instruments中运行我们的app,以确定阻塞主线程的内容.不幸的是,结果相当不透明.这是我从仪器获得的最重的堆栈跟踪.
它似乎是保存持久存储的更新,但我无法确定.所以我完全删除了任何调用,saveContext
因此MOC不会触及磁盘,并且主线程上的阻塞调用仍然存在.
文本形式的跟踪如下所示:
Symbol Name
-[NSManagedObjectContext(_NestedContextSupport) _parentObjectsForFetchRequest:inContext:error:]
-[NSManagedObjectContext executeFetchRequest:error:]
-[NSManagedObjectContext(_NestedContextSupport) executeRequest:withContext:error:]
_perform
_dispatch_barrier_sync_f_invoke
_dispatch_client_callout
__82-[NSManagedObjectContext(_NestedContextSupport) …
Run Code Online (Sandbox Code Playgroud) user-interface core-data objective-c nsmanagedobjectcontext ios
我正试图在我的NSTextFields中垂直居中文本,但其中一个是密码,所以它是一个NSSecureTextField.我已经将它的类设置MDVerticallyCenteredSecureTextFieldCell
为以下实现:
- (NSRect)adjustedFrameToVerticallyCenterText:(NSRect)frame {
// super would normally draw text at the top of the cell
NSInteger offset = floor((NSHeight(frame) -
([[self font] ascender] - [[self font] descender])) / 2);
return NSInsetRect(frame, 0.0, offset+10);
}
- (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView
editor:(NSText *)editor delegate:(id)delegate event:(NSEvent *)event {
[super editWithFrame:[self adjustedFrameToVerticallyCenterText:aRect]
inView:controlView editor:editor delegate:delegate event:event];
}
- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView
editor:(NSText *)editor delegate:(id)delegate
start:(NSInteger)start length:(NSInteger)length {
[super selectWithFrame:[self adjustedFrameToVerticallyCenterText:aRect]
inView:controlView editor:editor delegate:delegate
start:start length:length];
}
- (void)drawInteriorWithFrame:(NSRect)frame inView:(NSView *)view {
[super …
Run Code Online (Sandbox Code Playgroud) objective-c ×7
ios ×4
macos ×2
avfoundation ×1
calayer ×1
code-signing ×1
core-data ×1
image ×1
ios6 ×1
iphone ×1
jasmine ×1
mongodb ×1
mongoose ×1
node.js ×1
nstextfield ×1
uikit ×1
unit-testing ×1
video ×1
xcode ×1