Вопрос по ios, iphone – Несколько пользовательских строк UITableView?

2

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell=nil;
    //We use CellType1 xib for certain rows
    if(indexPath.row==0){
        static NSString *CellIdentifier = @"ACell";
        cell =(ACell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if(cell==nil){
            NSArray *nib= [[NSBundle mainBundle] loadNibNamed:@"ACell" owner:self options:nil];
            cell = (ACell *)[nib objectAtIndex:0];
        }
        //Custom cell with whatever
        //[cell.customLabelA setText:@"myText"]
    }
    //We use CellType2 xib for other rows
    else{
        static NSString *CellIdentifier = @"BCell";
        cell =(BCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if(cell==nil){
            NSArray *nib= [[NSBundle mainBundle] loadNibNamed:@"BCell" owner:self options:nil];
            cell = (BCell *)[nib objectAtIndex:0];
        }
        //Custom cell with whatever
        //[cell.customLabelB setText:@"myText"]
    }

    return cell;
}

Ваш Ответ

2   ответа
3

tvCell-tableView:cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *MyIdentifier1 = @"MyIdentifier1";
    static NSString *MyIdentifier2 = @"MyIdentifier2";
    static NSString *MyIdentifier3 = @"MyIdentifier3";
    static NSString *MyIdentifier4 = @"MyIdentifier4";

    NSUInteger row = indexPath.row

    UITableViewCell *cell = nil;

    if (row == 0) {
        cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifer1];
        if (nil == cell) {
            [[NSBundle mainBundle] loadNibNamed:@"MyTableCell1" owner:self options:nil];
            cell = self.tvCell;
            self.tvCell = nil;
        }
    }
    else if (row == 1) {
        cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifer2];
        if (nil == cell) {
            [[NSBundle mainBundle] loadNibNamed:@"MyTableCell2" owner:self options:nil];
            cell = self.tvCell;
            self.tvCell = nil;
        }
    }
    else if (row == 2) {
        cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifer3];
        if (nil == cell) {
            [[NSBundle mainBundle] loadNibNamed:@"MyTableCell3" owner:self options:nil];
            cell = self.tvCell;
            self.tvCell = nil;
        }
    }
    else if (row == 4) {
        cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifer4];
        if (nil == cell) {
            [[NSBundle mainBundle] loadNibNamed:@"MyTableCell4" owner:self options:nil];
            cell = self.tvCell;
            self.tvCell = nil;
        }
    }
    // etc.

    // Do any other custom set up for your cell

    return cell;

}
Error: User Rate Limit Exceeded
7



#import <UIKit/UIKit.h>
@interface CellType1 : UITableViewCell

@property(nonatomic,strong) IBOutlet UILabel *customLabel;

@end

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell=nil;
//We use CellType1 xib for certain rows
if(indexPath.row==<whatever you want>){
     static NSString *CellIdentifier = @"CellType1";
     cell =(CellType1*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
     if(cell==nil){
        NSArray *nib= [[NSBundle mainBundle] loadNibNamed:@"CellType1" owner:self options:nil];
        cell = (CellType1 *)[nib objectAtIndex:0];
      }
      //Custom cell with whatever
      [cell.customLabel setText:@"myText"]
}
//We use CellType2 xib for other rows
else{
    static NSString *CellIdentifier = @"CellType2";
    cell =(CellType2*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
     if(cell==nil){
        NSArray *nib= [[NSBundle mainBundle] loadNibNamed:@"CellType2" owner:self options:nil];
        cell = (CellType2 *)[nib objectAtIndex:0];
      }
      //Custom cell with whatever
      [cell.customLabel setText:@"myText"]
}

return cell;
}
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded Mateus
Error: User Rate Limit Exceeded Mateus
Error: User Rate Limit Exceeded Mateus
Error: User Rate Limit Exceeded

Похожие вопросы