Closed. This question is off-topic。它当前不接受答案。
想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
6年前关闭。
如何根据图像的高度对图像的NSMutableArray进行排序?
我需要找到每个图像的高度并按顺序添加它,还是有一种更简单的方法?
想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
6年前关闭。
如何根据图像的高度对图像的NSMutableArray进行排序?
我需要找到每个图像的高度并按顺序添加它,还是有一种更简单的方法?
最佳答案
如果它是UIImage对象的数组,则可以使用以下方法:
NSArray * sortedArray = [source sortedArrayUsingComparator:^(id obj1, id obj2){
UIImage *t1 = (UIImage *)obj1;
UIImage *t2 = (UIImage *)obj2;
if (t1.size.height > t2.size.height)
return (NSComparisonResult)NSOrderedAscending;
else
return (NSComparisonResult)NSOrderedDescending;
}];
关于iphone - 如何对图像数组进行排序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18020836/