让我们假设我有一个像这样的数组
NSArray* arr = @[@"1",@"4",@"2",@"8",@"11",@"10",@"14",@"9"]; //note: strings containing numbers
Run Code Online (Sandbox Code Playgroud)
我想这样排序:[1,2,4,8,9,10,11,14]
但是,如果我使用
[arr sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
Run Code Online (Sandbox Code Playgroud)
我得到[1,10,11,14,2,4,8,9] ......如果我使用:
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"length" ascending:YES];
NSArray *sortDescriptors = @[sortDescriptor];
[arr sortedArrayUsingDescriptors:sortDescriptors];
Run Code Online (Sandbox Code Playgroud)
我得到这样的东西:[1,4,2,8,9,11,10,14]
我如何组合两个谓词?或者是解决这个问题的其他更简单的方法吗?注意:此数组的输出仅用于调试目的,我不在乎结果是否将数组转换为整数,只要我可以在控制台中使用NSLog打印谢谢
所以我在使用ios 5的ipad 1上安装ad-hoc分发应用程序时遇到问题.我在其他ipads中安装时没有这个问题...这里安装失败后的控制台日志:
3月16日19:09:58 iPad SpringBoard [635]:杀死com.myapp.ipad进行应用安装
3月16日19:10:03 iPad ReportCrash [743]:制定流程安装的崩溃报告[739]
3月16日19:10:03 iPad com.apple.itunesstored [736]:receive_message:失败运行异步功能:1
3月16日19:10:03 iPad com.apple.itunesstored [736]:call_and_response:无法从代理收到回复
3月16日19:10:03 iPad com.apple.itunesstored [736]:MobileInstallationInstall:失败,带-1
3月16日19:10:04 iPad ReportCrash [743]:使用uid将崩溃报告保存到/var/mobile/Library/Logs/CrashReporter/installd_2014-03-16-191003_iPad.plist:0 gid:0,synthetic_euid:501 egid:0
3月16日19:10:04 iPad com.apple.launchd [1](com.apple.mobile.installd [739]):( com.apple.mobile.installd)作业似乎已经崩溃:分段错误:11
当互联网成为可能时,是否有可能在我的应用程序内收到通知或内容.我知道可达性和各种东西.但我想要的是当互联网在设备上可用时启动一些待定的NSUrlConnections.有没有一种简单的方法可以做到这一点,因为我不想使用循环线程来不断检查可达性.有什么建议?
我正在制作报刊亭应用,我需要在一个视图中使用多个组件.我有一个UIViewController显示和管理pdf(缩放,滚动等...)但我不希望它是全屏而不是我希望它像一个UIView内部另一个UIViewController有一个菜单在顶部,页面编号底部和其他工具.两者都是UIViewController...的子类我已经分别工作了.我只想把pdf查看器放在另一个里面.可能吗?这里有一些我想要的代码(可以说是在里面viewDidLoad)......但显然不起作用.任何帮助表示赞赏.它也必须是IOS 5.1.1兼容及以上
NSString *path = [[NSBundle mainBundle] pathForResource:@"myPdf" ofType:@"pdf"];
PDFViewController *page = [[PDFViewController alloc] initWithPDFAtPath:path];
//pdfView is a UIView of size 600x600 right in the middle
[self setPdfView:[page view]]; //this doest work... but it's basically what I want instead of presenting a viewController
//[self presentViewController:page animated:YES completion:NULL];
Run Code Online (Sandbox Code Playgroud)
我也知道这一点,但我不明白......如果这是我想要一些指导的方式:
addChildViewController:
willMoveToParentViewController:
didMoveToParentViewController:
Run Code Online (Sandbox Code Playgroud) 我的问题类似于上传后的iOS UIImagePickerController结果图像方向,而不是我需要修复视频方向的图像.视频也是使用imagePickerController捕获的,所以我基本上都有视频的URL.我需要将视频转换为NSData以将其上传到服务器,但在服务器上,视频方向与图像类似,具体取决于录制视频的方向.
NSURL * urlVideo;
//fix orientation here
NSData * videoDataToUpload = [NSData dataWithContentsOfURL:urlVideoFixed];
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止基于我从本教程得到的内容:http://www.raywenderlich.com/13418/how-to-play-record-edit-videos-in-ios但它不起作用
-(void)videoFixOrientation{
AVAsset *firstAsset = [AVAsset assetWithURL:[self urlVideoLocalLocation]];
AVMutableComposition* mixComposition = [[AVMutableComposition alloc] init];
AVMutableCompositionTrack *firstTrack = [mixComposition addMutableTrackWithMediaType:AVMediaTypeVideo preferredTrackID:kCMPersistentTrackID_Invalid];
[firstTrack insertTimeRange:CMTimeRangeMake(kCMTimeZero, firstAsset.duration) ofTrack:[[firstAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] atTime:kCMTimeZero error:nil];
AVMutableVideoCompositionLayerInstruction *FirstlayerInstruction = [AVMutableVideoCompositionLayerInstruction videoCompositionLayerInstructionWithAssetTrack:firstTrack];
AVAssetTrack *FirstAssetTrack = [[firstAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
UIImageOrientation FirstAssetOrientation_ = UIImageOrientationUp;
BOOL isFirstAssetPortrait_ = NO;
CGAffineTransform firstTransform = FirstAssetTrack.preferredTransform;
if(firstTransform.a == 0 && firstTransform.b == 1.0 && firstTransform.c …Run Code Online (Sandbox Code Playgroud) ios ×5
avfoundation ×1
ipad ×1
iphone ×1
nsarray ×1
objective-c ×1
orientation ×1
reachability ×1
uiview ×1
video ×1
xcode ×1