排序方法如下,其他代码请参考附件。

 

- (void) sortMoviesArray {
	NSSortDescriptor *sorter;
	switch (sortControl.selectedSegmentIndex) {
		case 0: 
			sorter = [[NSSortDescriptor alloc]
                      initWithKey:@"title" ascending:YES];
			break;
		case 1:  
			sorter = [[NSSortDescriptor alloc]
                      initWithKey:@"title" ascending:NO];
			break;
		case 2:
		default:
			sorter = [[NSSortDescriptor alloc]
                      initWithKey:@"boxOfficeGross" ascending:YES];
			break;
	}
	NSArray *sortDescriptors = [NSArray arrayWithObject: sorter];
	[moviesArray sortUsingDescriptors:sortDescriptors];
	[sorter release];
}

 

效果图:


给UITableView中的数据排序

相关文章:

  • 2021-12-13
  • 2021-04-27
  • 2021-06-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案