0
我一整天都在撞墙。我有UITableViewController
它有两个部分:第一个是可选的,具体取决于是否显示数据;第二总是有5个单元格。所有单元格都有UILabel
和UITextField
(根据数据,字段有时候会有选择器或日期选择器)。当我改变方向为风景时,整个桌子都会变得疯狂,并且在滚动时在各行之间以及各部分之间混合字段文本。我读过它与重用单元格有关,但迄今为止没有任何帮助。即使我保持存储领域的内容仍然被放错位置的新的数据模型......UITableView在景观中混合内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
SearchCell *cell = (SearchCell*)[tableView dequeueReusableCellWithIdentifier:@"SearchCell" forIndexPath:indexPath];
cell.valueField.delegate = self;
if (_attributesArray && indexPath.section == 0) {
cell.titleLabel.text = _attributesArray[indexPath.row][@"name"];
cell.valueField.text = _attributesArray[indexPath.row][@"value"];
switch ([_attributesArray[indexPath.row][@"type"] intValue]) {
case ATTR_INT:{
cell.valueField.keyboardType = UIKeyboardTypeNumberPad;
}
break;
case ATTR_DEC:{
cell.valueField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
}
break;
case ATTR_DATE:{
cell.valueField.inputView = self.datePicker;
}
break;
case ATTR_TEXT:{
cell.valueField.keyboardType = UIKeyboardTypeDefault;
}
break;
case ATTR_BOOL:{
// cell.valueField.inputView = self.choicePicker;
}
break;
}
}else{
switch (indexPath.row) {
case 0:{
cell.titleLabel.text = @"Name/Link";
cell.valueField.keyboardType = UIKeyboardTypeDefault;
}
break;
case 1:{
cell.titleLabel.text = @"Full text";
cell.valueField.keyboardType = UIKeyboardTypeDefault;
}
break;
case 2:{
cell.titleLabel.text = @"Uploaded before";
cell.valueField.inputView = self.datePicker;
}
break;
case 3:{
cell.titleLabel.text = @"Uploaded after";
cell.valueField.inputView = self.datePicker;
}
break;
case 4:{
cell.titleLabel.text = @"Document type";
// cell.valueField.inputView = self.choicePicker;
}
break;
}
}
return cell;
}
这是非常恼人的问题,在此先感谢
UPDATE
我想这一点,但没有迄今为止的运气。我将标签和字段值放在两个字典数组中,分为两部分。它的混合现在文本框在纵向和横向值...
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
SearchCell *cell;
if (_attributesArray && indexPath.section == 0) {
cell = (SearchCell*)[tableView dequeueReusableCellWithIdentifier:@"Attribute" forIndexPath:indexPath];
if (cell == nil) {
cell = [[SearchCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Attribute"];
}
cell.titleLabel.text = _attributesArray[indexPath.row][@"name"];
cell.valueField.text = _attributesArray[indexPath.row][@"value"];
cell.valueField.delegate = self;
}else{
cell = (SearchCell*)[tableView dequeueReusableCellWithIdentifier:@"Property" forIndexPath:indexPath];
if (cell == nil) {
cell = [[SearchCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Property"];
}
cell.titleLabel.text = _propertiesArray[indexPath.row][@"name"];
cell.valueField.text = _propertiesArray[indexPath.row][@"value"];
cell.valueField.delegate = self;
}
return cell;
}
都能跟得上:/依然一无所获,它不断得到即使在纵向模式混合 – raistlin