아래의 UITableView 셀은 검색 유형에 따라 텍스트 위치를 번갈아 표시합니다. 텍스트 레이블이 표준으로 설정되고 세부 텍스트가 현재 기울임 꼴로 설정됩니다. 나는 이것을 반대로하고 싶다.형식 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];
}
무엇이 문제입니까? 레이블 텍스트 설정에 대한 글꼴 설정에 동일한 유형의 조건부 표현식을 추가하기 만하면됩니다. 추악하지만 작동합니다. – allprog
나는 위의 질문을 명확하게하기 위해 그것을 조정했다. – Steve
만약'if genusSpecies : animal.commonName ...'은 무엇을 의미합니까? 이런 종류의 표현식에는':'연산자가 없다는 것이 확실합니다. 혹시라도 ==? – allprog