如何按字母顺序排序UITableView剖分? [英] How to sort alphabetically a UITableView Sectioned?

查看:145
本文介绍了如何按字母顺序排序UITableView剖分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个分区的UITableView有3个类别。我使用这个代码:

I have a sectioned UITableView with 3 categories. I'm using this code:

NSArray *arrayOne = [NSArray arrayWithObjects: @"one", @"two", "three", "four", nil];
    NSDictionary *dictOne = [NSDictionary dictionaryWithObject:arrayOne forKey:@"Elements"];

我按字母顺序排序?我在这里读了一些答案,但我没有找到任何东西。

How can i sort them alphabetically? I've read some answers here but i didn't found out anything.

如果我使用的代码在这个答案在UITableView中按字母顺序排序自定义对象的方法不起作用。
我有代码:

If i use the code in this answer Method for sorting custom objects alphabetically in UITableView it doesn't work. i have the code:

[listObjects addObject:dictOne];

如果我放

[listOfTitles sortUsingDescriptors:[NSArray arrayWithObject:titleSorter];

不起作用。

任何帮助赞赏

推荐答案

NSArray *arrayOne = [NSArray arrayWithObjects: @"one", @"two", "three", "four", nil];

NSArray *sortedArray = [arrayOne sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];


NSDictionary *dictOne = [NSDictionary dictionaryWithObject:sortedArray forKey:@"Elements"];

这篇关于如何按字母顺序排序UITableView剖分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆