为了与UISegmentedControl进行排序,如何设计UITableView的数据源? [英] How does one design the datasource for a UITableView in order to sort with a UISegmentedControl?

查看:67
本文介绍了为了与UISegmentedControl进行排序,如何设计UITableView的数据源?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计和编码iPhone应用程序以显示电影播放时间.我目前有一个包含以下内容的电影课:

I am in the process of designing and coding an iPhone application to display movie times. I currently have a Movie Class which contains:

  • NSString title
  • NSSDate releaseDate
  • NSSDate score
  • NSString title
  • NSSDate releaseDate
  • NSSDate score

我的UI是一个简单的UINavigationController,它的标题具有分段控件,而UITableView则用于在Interface Builder中显示电影设置.分段控件具有3个分段:标题,开幕日期和得分(在RottenTomatoes上).表格视图的数据当前由NSMutableArray movies提供,这是AppDelegate的属性.

My UI is a simple UINavigationController which has a segmented control as it's title and UITableView to display the Movies setup in Interface Builder. The segmented control has 3 segments: Title, Opening Date, and Score (on RottenTomatoes). The data for the table view is currently provided by a NSMutableArray movies which is a property of the AppDelegate.

我知道我可以使用以下代码注册目标动作,但是目前我不确定如何对UITableView数据进行排序:

I know that I can register target actions using the following code, but I am unsure of how to sort the UITableView data at this point:

[segmentedControl addTarget:self action:@selector(action:) forControlEvents:UIControlEventValueChanged];

每当UISegmentedControl选定的细分发生变化时,如何以及在何处诉诸UITableView?

How and where do I resort the UITableView whenever the UISegmentedControl selected segment changes?

推荐答案

此外,您还可以使用NSArray中的任何sortArrayUsing xxx方法对数据进行排序.

Also, you can sort the data with any of the sortArrayUsingxxx methods in NSArray.

这篇关于为了与UISegmentedControl进行排序,如何设计UITableView的数据源?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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