在我的应用程序中,我有一个经度为1的固定位置.现在,使用iPhone设备的用户可以移动到任何地方,甚至他可以旋转他的设备,箭头(一些uiimageview)应该指向该修复位置,这样用户每次都会获得指向该位置的方向.我尝试如下.
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
CLLocationCoordinate2D here = newLocation.coordinate;
[self calculateUserAngle:here];
}
-(void) calculateUserAngle:(CLLocationCoordinate2D)user {
NSLog(@"my destination is %f ; %f", fixlocLat, fixlocLon);
degrees = degrees + atan2(sin(fixlocLon-user.longitude)*cos(fixlocLat),cos(user.latitude)*sin(fixlocLat) - sin(user.latitude)*cos(fixlocLat)*cos(fixlocLon-user.longitude));
//get angle between user location and fix location
}
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
{
arrow.transform = CGAffineTransformMakeRotation((degrees-newHeading.trueHeading) * M_PI / 180);
}
Run Code Online (Sandbox Code Playgroud)
但上面的代码总是将箭头旋转到约.每个位置北2-3度.
我的问题类似于这个Stack Overflow问题.但是使用此链接中的代码我的方向错误.请帮帮我.
如果任何使用加速度计或gyrodata的想法对我有帮助.
提前.
iphone xcode objective-c cllocationmanager compass-geolocation
我想从资源网址将视频保存到我的应用文档中.我的资产网址如下: -
"assets-library://asset/asset.MOV?id=1000000394&ext=MOV"
Run Code Online (Sandbox Code Playgroud)
我试过这个: -
NSString *str=@"assets-library://asset/asset.MOV?id=1000000394&ext=MOV";
NSData *videoData = [NSData dataWithContentsOfURL:[NSURL URLWithString:str]];
[videoData writeToFile:mypath atomically:YES];
Run Code Online (Sandbox Code Playgroud)
但在第二行[NSData dataWithContentsOfURL:[NSURL URLWithString:str]]我得到了程序崩溃的原因: - 由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [NSURL长度]:发送到实例的无法识别的选择器
我想知道如何访问资产视频网址.
Thanx任何帮助.
我在低质量转换中使用简单的视频压缩代码.我正在使用IOS-4.2.1在iphone 4中测试我的代码.问题是当我在没有断点的设备上测试我的代码时代码无法创建视频(它只是零创建kb文件或空文件)但是当我逐行使用断点检查这段代码时,它会生成一个完美的压缩视频,也可以在mac中的quicktime播放器上运行.压缩后我制作了这个视频文件的zip.
NSURL *videoURL=[[self.videourlarray objectAtIndex:i] valueForKey:UIImagePickerControllerReferenceURL];
NSURL *outputURL = [NSURL fileURLWithPath:videoFile];
[[NSFileManager defaultManager] removeItemAtURL:outputURL error:nil];
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:videoURL options:nil];
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetLowQuality];
exportSession.outputURL = outputURL;
exportSession.shouldOptimizeForNetworkUse = YES;
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
[exportSession exportAsynchronouslyWithCompletionHandler:^(void)
{
NSLog(@"Export Complete %d %@", exportSession.status, exportSession.error);
[exportSession release];
}];
Run Code Online (Sandbox Code Playgroud)
thanx任何帮助......