1

優先順位LowMediumHighcustom Pickerの があります。

2 つのラベルを持つ Acustom Tableがありmain_Viewます。1 つはアイテム名、もう 1 つはアイテムの優先度です。

ユーザーが優先度を選択して必要なデータを挿入すると、アイテム名アイテムの優先度main_Viewを取得する場所に移動します。

私はこれを達成しましたが、私が望むのは、上の項目をmain_View優先順位に従って配置する必要があることです。つまり、 HighestMedium、次にLowです。

static NSString CellIdentifier = @"Cell"; 
RecordList *records = [tablecontentArray objectAtIndex:indexPath.row]; 
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) 
{ 
    NSArray *xibPath = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil]; 
    for (id fileObjects in xibPath) 
    {
        cell = (CustomCell)fileObjects; 
    } 
} 
cell.itemName.text =records.toDoItem; 
cell.itemPriority.text = records.toDoPriority; 

return cell; 
4

2 に答える 2

0
-(void)viewWillAppear:(BOOL)animated
{
    NSManagedObjectContext *objMOC = [appDelegate managedObjectContext];
    NSFetchRequest *fetch = [[NSFetchRequest alloc] init];
    [fetch setEntity:[NSEntityDescription entityForName:@"RecordList" inManagedObjectContext:objMOC]];
    tablecontentArray = [[NSMutableArray alloc] initWithArray:[objMOC executeFetchRequest:fetch error:nil]];
    sortArray = [[NSMutableArray alloc] init];

    for (RecordList *strH in tablecontentArray) {
        if ([strH.toDoPriority hasPrefix:@"H"]) {
            [sortArray addObject:strH];
        }
    }
    for (RecordList *strH in tablecontentArray) {
        if ([strH.toDoPriority hasPrefix:@"M"]) {
            [sortArray addObject:strH];
        }
    }for (RecordList *strH in tablecontentArray) {
        if ([strH.toDoPriority hasPrefix:@"L"]) {
            [sortArray addObject:strH];
        }
    }

    [homeTable reloadData];
}


-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return sortArray.count;
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    RecordList *records = [sortArray objectAtIndex:indexPath.row];

    CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        NSArray *xibPath = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];

        for (id fileObjects in xibPath) {
            cell = (CustomCell*)fileObjects;
        }

    }


      cell.itemName.text =records.toDoItem;
      cell.itemPriority.text = records.toDoPriority;

    return cell;
}
于 2013-05-29T06:03:23.187 に答える