Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.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
customcell在ios中未显示完整阵列数据_Ios_Uitableview - Fatal编程技术网

customcell在ios中未显示完整阵列数据

customcell在ios中未显示完整阵列数据,ios,uitableview,Ios,Uitableview,重要的因素是,如果我在cell.textlabel中打印数组,它将打印所有值,但我希望在dynamic uilabel中打印数组值,那么我如何才能做到这一点 This problem taking more time. i am just adding set of array values to table view array contains totally 12 values but it is just showing 3 values. if i am change row heig

重要的因素是,如果我在cell.textlabel中打印数组,它将打印所有值,但我希望在dynamic uilabel中打印数组值,那么我如何才能做到这一点

This problem taking more time. i am just adding set of array values to table view array contains totally 12 values but it is just showing 3 values. if i am change row height more it is just displaying 3 values. if i reduce row height it showing all values so any one can help me how i can show all array value but my row height should be more than 100.

这是我的代码,如果有人能给出解决方案,我会非常高兴的。你应该在if(){}之后向你的单元格询问UILabel,因为UILabel*lab不仅对新单元格是零,对重复使用的单元格不是零

静态NSString*cellidentifier=@“ViewProfileCell”

建议:

向ViewProfileCell类添加属性声明

@属性(非原子、强、只读)UILabel*nameLabel

添加合成

并实现惰性getter:

ViewProfileCell *cell=(ViewProfileCell*)[tableView dequeueReusableCellWithIdentifier:cellidentifier];

if(!cell)
{
    NSArray *nibofviewProfile=[[NSBundle mainBundle]loadNibNamed:@"ViewProfileCell" owner:self options:Nil];
    cell=[nibofviewProfile objectAtIndex:0];
    UILabel *lab =[[UILabel alloc]init];
    lab.frame=CGRectMake(80, 10, 30, 50);
    lab.tag = 123;
    [cell.contentView addSubview:lab];
}
UILabel *lab = [cell.contentView viewWithTag:123]; lab.text=[name objectAtIndex:indexPath.row];
因此,您的代码将是

- (UILabel *)nameLabel
{
if (_nameLabel) return _nameLabel;

_nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(80, 10, 30, 50)];
[self.contentView addSubview:_nameLabel;
return _nameLabel;
}

只需初始化ViewProfileCell*单元格=[[ViewProfileCell alloc]init];为什么要再次创建带标签的UIlabel*实验室?我不是在创建它。我要求提前创建一个。您最好在IB中添加此标签,并在ViewProfileCell上创建readonly属性以返回此标签。它工作正常,非常感谢您的帮助!!但是有一个疑问,我不知道你在这里创建的标签的用途,如果你解释它会非常有用,我将显示超过5个数据,如姓名、年龄、性别等。。在ViewProfileCell中创建动态标签还是直接拖动标签,哪个更好??
- (UILabel *)nameLabel
{
if (_nameLabel) return _nameLabel;

_nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(80, 10, 30, 50)];
[self.contentView addSubview:_nameLabel;
return _nameLabel;
}
static NSString *cellidentifier=@"ViewProfileCell";

    ViewProfileCell *cell=(ViewProfileCell*)[tableView dequeueReusableCellWithIdentifier:cellidentifier];

if(!cell)
    {
        NSArray *nibofviewProfile=[[NSBundle mainBundle]loadNibNamed:@"ViewProfileCell" owner:self options:Nil];
        cell=[nibofviewProfile objectAtIndex:0];
    }
   cell.nameLabel.text=[name objectAtIndex:indexPath.row];