如何在目标C中的自定义TableView UILabel上设置数据模型值 [英] How to set Data Model value on Custom TableView UILabel in Objective C
问题描述
我是iOS的新手,我面临有关在UIlabel上设置数据模型的问题
I am new in iOS and I am facing problem regarding to set Data Model on UIlabel
我曾经喜欢使用此代码进行更改
I used like this code to change
在ConnectiondidFinishLoading中
In ConnectiondidFinishLoading
AuditTextBoxarray=[[NSMutableArray alloc] init];
for(int i=0;i<idarray.count;i++)
{
DataModel *model = [DataModel new];
model.AuditTextBoxString = @"";
[AuditTextBoxarray addObject:model];
}
在cellforrowatindexpath中
In cellforrowatindexpath
cell.lblAuditTextBox.text=[NSString stringWithFormat:@"%@",[AuditTextBoxarray objectAtIndex:indexPath.row ]];
单击按钮
NSString *String=textView1.text;
DataModel *model = [AuditTextBoxarray objectAtIndex:index];
model.AuditTextBoxString = String;
但是我无法在表视图中设置数据模型的值:
But I am not able to set value of data model in tableview:
如何将数据模型值设置为uilabel?我做错了什么,但我没有得到.
How can I set Data Model value to uilabel? I am doing something wrong, but what I am not getting.
DataModel.h
DataModel.h
@interface DataModel : NSObject
@property(nonatomic, strong)NSString *strSelected;
@property(nonatomic,strong)NSString *TextViewvalue;
@property(nonatomic,strong)NSString *RateViewValue;
@property(nonatomic,strong)NSString *Popupvalue;
@property(nonatomic,strong)NSString *SurveySelected;
@property(nonatomic,strong)NSString *AuditTextBoxString;
DataModule.m
DataModule.m
#import "DataModel.h"
@implementation DataModel
@end
我使用DataModule来更改Button颜色,并将其设置在表格视图中
I used DataModule to change Button colour and set it on the table view like this
在ConnectionDidFinishLoading中
In ConnectionDidFinishLoading
for (int i =0; i<idarray.count; i++)
{
DataModel *model = [DataModel new];
model.strSelected = @"";
[arrData addObject:model];
}
按钮单击
sender.backgroundColor = [UIColor redColor];
DataModel *model = [arrData objectAtIndex:sender.tag];
model.strSelected = @"P";
cellforrowatindexoath
cellforrowatindexoath
//background color change on button
DataModel *model = [arrData objectAtIndex:indexPath.row];
if([model.strSelected isEqualToString:@"P"])
{
cell.passbtn.backgroundColor = [UIColor redColor];
}
现在,我正在尝试在uilabel frok数据模型上添加文本.
Now I am trying to add text on uilabel frok data model.
推荐答案
我只是从
cell.lblAuditTextBox.text=[NSString stringWithFormat:@"%@",[AuditTextBoxarray objectAtIndex:indexPath.row ]];
收件人
DataModel *model = [AuditTextBoxarray objectAtIndex:indexPath.row];
cell.lblAuditTextBox.text=model.AuditTextBoxString
这篇关于如何在目标C中的自定义TableView UILabel上设置数据模型值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!