Представление содержимого не отображается при тестировании в Objective-C - PullRequest
0 голосов
/ 04 июля 2018

Я довольно новичок в Objective-C, и я застрял в этой части. Я пытаюсь отобразить элементы управления, текстовое поле, метку, градиентные представления и кнопку «Перенос», которые находятся внутри представления содержимого ячейки, но оно не отображается при его проверке. Он показывает только «1. Данные для работы» дважды, но без содержимого. Может кто-нибудь помочь мне с этим? Буду признателен за это.

Ниже показано, как выглядит мой ViewController:

@implementation CNCTransfersOwnViewController{

}

//@synthesize delegate;


+ (id)instanceFromStoryboard {
    return [self instanceFromStoryboardNamed:@"Transfer"];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUpUI];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)setUpUI {
    self.navigationBar.topItem.title = @"GO TO SOMEWHERE ELSE";
}

- (NSString *)identifierForCellAtIndexPath:(NSIndexPath *)indexPath {
    NSString *identifier = @"";

            identifier = @"OPERATION";

    return identifier;
}

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    if(self.tableView == tableView){
        return 2;
    }else{
        return 0;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    if(self.tableView == tableView){
        NSString *identifier = [self identifierForCellAtIndexPath:indexPath];

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }

    return nil;
}

1 Ответ

0 голосов
/ 04 июля 2018

Вам необходимо установить текст, который вы хотите отображать в методе cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if(self.tableView == tableView){
        NSString *identifier = [self identifierForCellAtIndexPath:indexPath];

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        cell.textLabel.text = @"The text you want to display";
        return cell;
    }
    return nil;
}
...