0

以下の UITableView セルは、検索タイプに応じてテキストの場所を変更します。現在、テキスト ラベルは標準に設定されており、詳細テキストは斜体に設定されています。これが逆であってほしい。

つまり、genusSpecies : animal.commonName の場合、textLabel = ItalicFont の場合、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];

}
4

2 に答える 2