我想实现以下目标:
我希望用户能够使用陀螺仪"记录"iPhone的运动.之后,用户应该能够复制相同的动作.我使用以下方法提取俯仰,滚转和偏航:
[self.motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue]
withHandler: ^(CMDeviceMotion *motion, NSError *error)
{
CMAttitude *attitude = motion.attitude;
NSLog(@"pitch: %f, roll: %f, yaw: %f]", attitude.pitch, attitude.roll, attitude.yaw);
}];
Run Code Online (Sandbox Code Playgroud)
我想如果用户处于记录模式,我可以将这些值存储到数组中.当用户尝试复制该移动时,我可以将复制的移动阵列与录制的移动阵列进行比较.问题是,如何以智能方式比较两个阵列?它们永远不会具有完全相同的值,但它们可能有些相同.
我在这里走在正确的轨道上吗?
更新:我想也许Alis回答有关使用DTW的方法对我来说可能是正确的方法.但是我并不那么聪明(显然),所以如果有人能帮助我完成与阵列比较的第一步,我会是一个快乐的人!
谢谢!
iphone math android artificial-intelligence gesture-recognition
我有一个带声音录制的视频.将其添加到AVMutableComposition然后将其导出时,视频将在播放声音时冻结.我错过了什么?
我有两条曲目:
_compositionVideoTrack = [self.composition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
_compositionAudioTrack = [self.composition addMutableTrackWithMediaType:AVMediaTypeAudio preferredTrackID:kCMPersistentTrackID_Invalid];
Run Code Online (Sandbox Code Playgroud)
然后创建轨道:
AVAssetTrack *clipVideoTrack = [[sourceAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
AVAssetTrack *clipAudioTrack = [[sourceAsset tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0];
Run Code Online (Sandbox Code Playgroud)
然后我插入曲目:
[_compositionVideoTrack insertTimeRange:editRange ofTrack:clipVideoTrack atTime:self.composition.duration error:&editError];
[_compositionAudioTrack insertTimeRange:editRange ofTrack:clipAudioTrack atTime:self.composition.duration error:&editError];
Run Code Online (Sandbox Code Playgroud)
最后我导出它:
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:urlAsset presetName:AVAssetExportPresetPassthrough];
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
Run Code Online (Sandbox Code Playgroud)
该文件是.mp4.它可能是文件格式吗?
当我尝试在我的设备上运行我的UI测试时,我收到错误:
XCTRunner [1476:104021]无法加载捆绑包"AppUITests",因为它已损坏或缺少必要的资源.尝试重新安装捆绑包.2015-11-23 20:58:53.903 XCTRunner [1476:104021](dlopen_preflight(/var/mobile/Containers/Bundle/Application/FAC2EFB2-92C6-4668-96A7-C77CC5C4AE87/AppUITests-Runner.app/PlugIns/AppUITests. xctest/TrueMostUITests):未加载库:@ rpath/UIColor_Hex_Swift.framework/UIColor_Hex_Swift参考自:/var/mobile/Containers/Bundle/Application/FAC2EFB2-92C6-4668-96A7-C77CC5C4AE87/AppUITests-Runner.app/PlugIns/AppUITests .xctest/AppUITests原因:图片未找到)
在这种情况下,它是"UIColor_Hex_Swift.framework",它位于我的podfile中.但是我从cocoapods加载哪个框架并不重要.它会在每个框架上失败.
我已经尝试更改pod文件,清理,删除派生数据,重新安装pod和更改签名.不,我没有想法.
如果我使用模拟器,一切正常.
这是我的pod文件:
platform :ios, '9.0'
workspace './AppWorkspace'
use_frameworks!
inhibit_all_warnings!
link_with 'App', 'AppTests', 'AppUITests'
target 'App', :exclusive => false do
pod 'SwiftyJSON', '~> 2.3.0'
pod 'MQTTKit', :git => 'https://github.com/mobile-web-messaging/MQTTKit.git'
pod 'PromiseKit', '~> 3.0.0'
pod 'UIColor_Hex_Swift',:git => 'https://github.com/yeahdongcn/UIColor-Hex-Swift.git', :branch => 'Swift-2.0'
pod 'OHHTTPStubs', '~> 4.3.0'
pod 'Alamofire', '~> 3.1.0'
end
def testing_pods()
# pod 'SwiftyJSON', '~> 2.3.0'
# pod 'MQTTKit', :git => 'https://github.com/mobile-web-messaging/MQTTKit.git'
# pod 'PromiseKit', '~> 3.0.0'
pod 'UIColor_Hex_Swift',:git => …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个UICollectionView,其行为类似于iPad上的photos.app(捏合分组和扩展).
你认为photos.app是如何构建的?
您认为最好的方法是什么?
谢谢
我有一个可可项目正处于开发的后期阶段.我使用Core Data和绑定.
最近我想测试magicalRecord,因为它似乎可以帮助我减少很多繁琐的coredata代码甚至是子类化实体.
这似乎是一个使用cocapods的直接实现.
题
将magicalRecord实现到现有的CoreData项目是一个好主意,如果是这样,它最好怎么做?我主要考虑的是我现有的商店和代码.
谢谢
这是在iOS上.
我有一个核心数据库,有大约35万个对象.对象(Product)有两个属性:"条形码"和"指定".用户可以通过搜索"条形码"来搜索对象,并且应该返回"指定".一切都很好,除了它很慢.我使用的代码是:
NSEntityDescription *_product = [NSEntityDescription entityForName:@"Product" inManagedObjectContext:importContext];
NSFetchRequest *fetch = [[NSFetchRequest alloc]init];
[fetch setEntity:_product];
[fetch setPredicate:[NSPredicate predicateWithFormat:@"Barcode == %@",theBarcode]];
NSError *error = nil;
NSArray *results = [importContext executeFetchRequest:fetch error:&error];
NSManagedObject *object = [results objectAtIndex:0];
Run Code Online (Sandbox Code Playgroud)
由于我只想获取一个对象,有没有办法加快速度?
如果我在启动时将每个对象加载到一个数组中,那么应用程序的启动速度非常慢,占用大量内存.
提前致谢!
编辑:我添加了[fetch setFetchLimit:1]; 这加快了一点点.但是数据库中对象的速度越来越慢.
我正在从Obj-C过渡到Swift,5秒钟后我被卡住了:/
@IBOutlet var scene: SCNView!我得到错误:
'weak' cannot be applied to non-class type '<<error type>>'
Use of undeclared type 'SCNView'
Run Code Online (Sandbox Code Playgroud)
这是什么?
我正在使用最新的Xcode 6.3。
我想制作一个uiTableview应用程序,它的大小是屏幕的四分之一.我使用基于导航的应用程序启动了该项目.现在我想更改表视图以不填满整个屏幕,但还没有设法这样做.我在网上搜索了一个答案,但一直无法找到解决方案.
如果我将tableview放入'RootViewController.xib'中的另一个视图,我是否在正确的轨道上?
提前致谢!
ios ×6
iphone ×3
core-data ×2
android ×1
avfoundation ×1
cocoa ×1
math ×1
objective-c ×1
scenekit ×1
storyboard ×1
swift ×1
uitableview ×1
uiview ×1
xcode ×1
xctest ×1