gpt4 book ai didi

ios - UITableView 中不可见的标签文本

转载 作者:行者123 更新时间:2023-11-28 21:49:45 25 4
gpt4 key购买 nike

我已经为最基本的创建了一个自定义表格。我制作了一个标签栏 Controller 。

FoglalasTableViewCell.h

@interface FoglalasTableViewCell : UITableViewCell

@property (weak, nonatomic) IBOutlet UILabel *datumLabelFoglalas;
@property (weak, nonatomic) IBOutlet UILabel *adminNevekLabelFoglalas;

@end

FoglalasTableViewCell.m

#import "FoglalasTableViewCell.h"

@implementation FoglalasTableViewCell


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}

- (void)awakeFromNib
{
// Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];

// Configure the view for the selected state
}

@end

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

FoglalasTableViewCell *Cellw = [tableView dequeueReusableCellWithIdentifier:CellIdent];

if (!Cellw) {
Cellw = [[FoglalasTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdent];
// Cellw = [[FoglalasTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdent];
}

if (Cellw.backgroundView == nil) {

if ([foglaltArr[indexPath.row] isEqual: @0]) {
[Cellw setBackgroundColor:[UIColor greenColor]];
} else if ([foglaltArr[indexPath.row] isEqual: @1]) {
[Cellw setBackgroundColor:[UIColor redColor]];
}
}

NSLog(@"%d. foglaltArr : %@",indexPath.row, [foglaltArr objectAtIndex:indexPath.row]);

NSLog(@"%d orakArr %@",indexPath.row,orakArr[indexPath.row]);

Cellw.datumLabelFoglalas.text = [foglaltArr objectAtIndex:indexPath.row];
Cellw.adminNevekLabelFoglalas.text = @"blah..";

return Cellw;

}

我插入了数据源。它改变了单元格的背景颜色。但是标签没有获取数据源。我不明白为什么要得到背景的来源,为什么不得到标签!?我不知道如何解决。请帮助我。

![背景源可见][1]

最佳答案

我会将属性声明为 nonatomic, strong。我也会合成它们。

同时检查您将元素与您的 View 相关联。

最后才调用nib

FoglalasTableViewCell *cell = (FoglalasTableViewCell *)[tableView dequeueReusableCellWithIdentifier: CustomCellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"FoglalasTableViewCell" owner:self options:nil];
cell = (FoglalasTableViewCell *)[nib objectAtIndex:0];
}

关于ios - UITableView 中不可见的标签文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28759410/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com