Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/reporting-services/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITableView中不可见的标签文本_Ios_Objective C_Uitableview_Cell - Fatal编程技术网

Ios UITableView中不可见的标签文本

Ios UITableView中不可见的标签文本,ios,objective-c,uitableview,cell,Ios,Objective C,Uitableview,Cell,我已经创建了一个非常基本的自定义表。我做了一个tabbar控制器 FoglalasTableViewCell.h @interface FoglalasTableViewCell:UITableViewCell @性质(弱、非原子)IBUILabel*datumLabelFoglalas; @属性(弱、非原子)IBUILabel*adminNevekLabelFoglalas; @结束问题就在这里(我猜您没有使用原型单元) 您没有在这里加载xib,您只是创建了FoglalasTableView

我已经创建了一个非常基本的自定义表。我做了一个tabbar控制器

FoglalasTableViewCell.h

@interface FoglalasTableViewCell:UITableViewCell
@性质(弱、非原子)IBUILabel*datumLabelFoglalas;
@属性(弱、非原子)IBUILabel*adminNevekLabelFoglalas;
@结束
问题就在这里(我猜您没有使用原型单元)

您没有在这里加载xib,您只是创建了
FoglalasTableViewCell
对象,该对象具有
DatumLabelFoglas
AdminNevekLabelFoglas
作为
nil

使用

作为参考,你可以查一下


编辑:对于protype单元格,在情节提要中更改单元格的类名和标识符,并使用以下方法

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

    FoglalasTableViewCell *Cellw = [tableView dequeueReusableCellWithIdentifier: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;
}

我将把属性声明为
非原子、强
。我也会合成它们

还要检查是否已将图元与视图连接

最后只需给笔尖打电话

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

在main.storyboard中选择表视图单元格并填充标识符字段“foglalas”

谢谢教程,但没有解决我的问题,请查看我的错误日志:由于未捕获异常“NSInternalInconsistencyException”终止应用程序,原因:“无法在捆绑包中加载NIB:”NSBundle(已加载)名为“FoglalasTableViewCell”的“我使用序列图像板。您使用的是序列图像板,可能您正在序列图像板上创建称为原型单元的单元。是的。我使用情节串连板,并在sb中生成单元格。抱歉,有点不好:由于未捕获的异常而终止应用程序“NSInternalInconsistencyException”,原因:“UITableView数据源必须从tableView返回单元格:cellForRowAtIndexPath:”什么是MasterCell?这门课?@bolo对不起,我是从我工作的项目中抄来的。我把它编辑成了
FoglalasTableViewCell
谢谢你的速度。什么是错误?请看:由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法在捆绑包中加载NIB:“NSBundle(loaded)”,名称为“FoglalasTableViewCell”。您在情节提要中有单元吗?是的,我在情节提要中有单元。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdent = @"foglalas";

    FoglalasTableViewCell *Cellw = [tableView dequeueReusableCellWithIdentifier: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;
}
FoglalasTableViewCell *cell = (FoglalasTableViewCell *)[tableView dequeueReusableCellWithIdentifier: CustomCellIdentifier];
if (cell == nil) {
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"FoglalasTableViewCell" owner:self options:nil];
    cell = (FoglalasTableViewCell *)[nib objectAtIndex:0];
}