小编Dha*_*wal的帖子

如何将方向箭头旋转到特定位置

在我的应用程序中,我有一个经度为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

14
推荐指数
2
解决办法
2万
查看次数

DeviceCheck - 如何在同一设备上处理多个应用程序

根据 DeviceCheck API文档WWDC 视频,DeviceCheck 位是每个设备和每个 teamID 那么我们如何处理这些场景呢?

  1. 如果我们有多个提供试用促销优惠的应用程序在同一个 teamID 下上传 ,这些应用程序的 DeviceCheck 位将相同 那么我们如何确定哪个应用程序具有用户兑换的试用期。
  2. 我们如何处理设备销售情况,因为文档中没有太多相关信息。

iphone ios devicecheck

8
推荐指数
0
解决办法
186
查看次数

如何从资源网址中保存视频

我想从资源网址将视频保存到我的应用文档中.我的资产网址如下: -

"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任何帮助.

iphone xcode objective-c ios4 alasset

1
推荐指数
1
解决办法
9486
查看次数

带有和没有断点的AVAssetExportSession

我在低质量转换中使用简单的视频压缩代码.我正在使用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任何帮助......

iphone objective-c avfoundation ios4 avassetexportsession

1
推荐指数
1
解决办法
2332
查看次数