-4
A
回答
0
設計您的自定義單元格(使用自定義字體爲標籤,以獲取準確的外觀,如果必要的。)
定製單元設計
並自定義行的單元格的像這樣的索引委託方法。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// static NSString *CellIdentifier = @"Cell";
// UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// if (cell == nil) {
// cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
// }
//
// Configure the cell...
//Customiztion of cell
static NSString *[email protected]"cell";
SampleTableCell *cell = (SampleTableCell *) [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
NSString *customeCellName = [NSString stringWithFormat:@"%@",[SampleTableCell class]];
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:customeCellName owner:self options:nil];
for (id currentObject in topLevelObjects)
{
if ([currentObject isKindOfClass:[UITableViewCell class]])
{
cell = (SampleTableCell *) currentObject;
break;
}
}
}
cell.label1.text = @"Server";
cell.label2.text = @"vereist"
return cell;
}
+0
我正在使用故事板 – Shinonuma 2013-03-28 13:37:45
1
您需要爲您的表格創建自定義單元格,設計您的單元格。把textView或任何東西,並加載您的表與該自定義單元格。
0
這就是所謂的定製UITableViewCell
,有包括兩個控制
1 UILabel
2 UITextField
將這個兩個控制在cellForRowAtIndexPath
與具體FRAM大小。
OR
把這個整個代碼,因爲它是。
- (void)viewDidLoad
{
[super viewDidLoad];
self.tblView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height - 23) style:UITableViewStyleGrouped];
self.tblView.delegate = self;
self.tblView.dataSource = self;
self.tblView.backgroundView = nil;
self.tblView.backgroundColor = [UIColor clearColor];
self.tblView.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.view addSubview:self.tblView];
self.placeHolderValue = [[NSMutableArray alloc]initWithObjects:@"server ", @"account", @"Roof Coverings", @"Wall token", @"Roof", @"Floor", @"Guttering", nil];
self.textFields = [NSMutableArray array];
self.textLabels = [NSMutableArray array];
for (int i = 0; i < self.placeHolderValue.count; i++)
{
UITextField *textFiled = [[UITextField alloc] initWithFrame:CGRectMake(155.0, 0.0, 150.0, 44.0)];
textFiled.placeholder = @"Vereist";
textFiled.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
textFiled.autocorrectionType = UITextAutocorrectionTypeNo;
textFiled.autocapitalizationType = UITextAutocapitalizationTypeNone;
textFiled.borderStyle = UITextBorderStyleNone;
textFiled.clearButtonMode = UITextFieldViewModeAlways;
textFiled.delegate = self;
textFiled.tag = i+1;
textFiled.font = [UIFont systemFontOfSize:14];
if (self.listOfDetails.count > 0)
{
textFiled.text = [[self.listOfDetails objectAtIndex:0] objectForKey:[self.dbFieldName objectAtIndex:i]];
isEmpty = NO;
}
[self.textFields addObject:textFiled];
UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(15, 0, 140, 44)];
lab.text = [self.placeHolderValue objectAtIndex:i];
lab.textAlignment = NSTextAlignmentLeft;
lab.numberOfLines = 0;
lab.font = [UIFont systemFontOfSize:14];
lab.backgroundColor = [UIColor clearColor];
[self.textLabels addObject:lab];
}
}
#pragma mark -
#pragma mark Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return self.placeHolderValue.count;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
//static NSString *CellIdentifier = @"Cell";
NSString *CellIdentifier = [NSString stringWithFormat:@"S%1dR%1d",indexPath.section,indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell.contentView addSubview:[self.textLabels objectAtIndex:indexPath.row]];
[cell.contentView addSubview:[self.textFields objectAtIndex:indexPath.row]];
}
return cell;
}
相關問題
- 1. 保留表格視圖單元格的文本字段數據
- 2. 具有文本字段滾動問題的iOS表格視圖
- 3. 在表格視圖上添加文本字段按鈕點擊
- 4. 表格 - 某種colspan?
- 5. 如何在表格視圖中更改文本字段的字體
- 6. asp.net網格視圖綁定字段到文本框
- 7. 使用以前視圖中的文本字段中的數據填充表格視圖單元格
- 8. 從另一種方法訪問開關和表格視圖中的文本字段
- 9. 如何獲取文本並將其從文本字段存儲在表格視圖中單元格
- 10. 如何在iPhone的表格視圖中獲取文本字段值?
- 11. 如何過濾文本字段編輯的表格視圖數據 - IOS
- 12. 當文本字段開始編輯時,表格視圖滾動iphone
- 13. 如何管理包含文本字段的表格視圖的滾動
- 14. 如何查看其他文本字段中某個文本字段的文本?
- 15. 在Drupal視圖中更改視圖的字段文本
- 16. 術語來表示某種字段或某種類型的屬性
- 17. 不包含某些字段的視圖列表
- 18. 文本字段上的文本視圖在swift3中消失
- 19. 如何從文本字段插入文本到警報視圖
- 20. PHPmyadmin:選擇在某個表格字段上顯示的圖片?
- 21. 當滾動表格視圖單元格的視圖,單元格文本更改
- 22. 帶有多種文字顏色的文本視圖android
- 23. 如何比較表格外的文本視圖與表格行中的文本視圖?
- 24. 覆蓋Drupal視圖字段格式?
- 25. 在CSV文件中讀取某種格式的文本
- 26. 如果表格爲空,則從視圖中隱藏字段和字段名稱
- 27. 如何跨越表格單元格,文本字段
- 28. gettting didSelectRowAtIndexpath方法在自定義表格視圖單元格內的文本字段集中時調用
- 29. 如何在表格視圖中爲自定義單元格的文本字段固定標籤值?
- 30. 如何在分組表格視圖中創建文本字段iPhone中的單元格
即'UITextField'被添加到'UITableViewCell'子類中。 CUSTOM TABLEVIEWCELL – viral 2013-03-28 11:00:14