码迷,mamicode.com
首页 > 编程语言 > 详细

开发笔记之NSTable 排序

时间:2015-09-14 15:10:57      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:

(1)第一步设置一下button
    IBOutlet NSButton * nameOrderBT;
    IBOutlet NSButton * sizeOrderBT;
(2)切换设置切换相遇函数
-(IBAction) nameOrderAction:(id)sender
{
    
    [sizeOrderBT setTitle:@"Width"];
    if ([nameOrderBT.title isEqualToString:@"Name??"]) 
    {
        [nameOrderBT setTitle:@"Name??"];
        
        _itemOrder=RFICONMODEL_ORDER_FILENAME_DESC;
        
    }
    else{
        [nameOrderBT setTitle:@"Name??"];
        _itemOrder=RFICONMODEL_ORDER_FILENAME_ASC;
    }
    [self updateTable];
    return;
    
}
-(IBAction) sizeOrderAction:(id)sender
{
    [nameOrderBT setTitle:@"Name"];
    if ([sizeOrderBT.title isEqualToString:@"Width??"]) 
    {
        [sizeOrderBT setTitle:@"Width??"];
        _itemOrder=RFICONMODEL_ORDER_IMAGEWIDTH_DESC;
    }
    else{
        [sizeOrderBT setTitle:@"Width??"];
        _itemOrder=RFICONMODEL_ORDER_IMAGEWIDTH_ASC;
    }
    [self updateTable];
    return;

}

(3)设置item获取顺序

{
    if (_itemOrder==nil) {
        _itemOrder=@"";
        
    }
    return _itemOrder;
}


-(NSMutableArray*) getItemsArray
{
    if (itemsArray==nil) {
        itemsArray=[NSMutableArray array];
        //NSArray * modelArray=[RFIConModel getItemByGroupName:[self getGroupNameBySafe]];
        NSArray * modelArray=[RFIConModel getItemByGroupName:[self getGroupNameBySafe] order:[self getItemOrderBySafe]];
        for (RFIConModel * model in modelArray) {
            ItemPreCellVC * oneVC=[[ItemPreCellVC alloc] init];
            oneVC.itemModel=model;
            [itemsArray addObject:oneVC];
        }
    }
    return itemsArray;
}

其中[RFIConModel getItemByGroupName:[self getGroupNameBySafe] order:[self getItemOrderBySafe]]是order关键,这样只需设施一下itemOrder,就可自动更新内容了。

开发笔记之NSTable 排序

标签:

原文地址:http://www.cnblogs.com/springday/p/4807058.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!