下面的 UITableView 单元根据搜索类型交替文本位置。文本标签设置为标准,详细文本当前设置为斜体。我希望这是相反的。
即如果 genusSpecies : animal.commonName 那么 textLabel = ItalicFont else if animal.commonName : genusSpecies 那么 textLabel = StandardFont
我想将此规则应用于下面的代码。
- (void)setAnimal:(ITanimal *)animal forType:(ITSectionType)type {
_animal = animal;
BOOL isCommonType = (type == ITSectionTypeCommonName);
NSString *genusSpecies = animal.species];
[self.textLabel setFont:ItalicFont];
[self.textLabel setText:(!isCommonType)? genusSpecies : animal.commonName];
[self.detailTextLabel setFont:StandardFont];
[self.detailTextLabel setText:(!isCommonType)? animal.commonName : genusSpecies];
}