내 TableViewController에서 사용자 정의 셀을 사용하고 있습니다. 나는 회사에 관한 몇 가지 데이터를 보여주고있다. 회사 제목은 기본적으로 파란색으로 표시되어 있으며 회사에 유효한 URL이 없는지 확인하여 검정색으로 칠할 수 있습니다. 물론 회사에 유효한 URL이없는 경우 오프닝 회사 웹 사이트를 금지하는 논리를 추가했습니다.URL 검사가 제대로 작동하지 않습니다.
그러나이 테이블보기가 표시 될 때마다 제목이 검정으로 칠해진 유효한 URL이있는 회사가 여러 개 있습니다.
그래서 사파리에서 제목과 여는 URL을 채색하는 데 같은 논리를 사용하고 있지만 색상이 제대로 작동하지 않으며 사파리에서 열리지 않습니다.
어떤 아이디어가 잘못 되었나요?
여기 내 cellForRowAtIndexPath 기능
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"StandardSearchResultCell";
ResultsViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
Data *theData = [Data getInstance];
Company *theCompany = [theData.results objectAtIndex:indexPath.row];
cell.lblTitle.text = theCompany.DisplayName;
cell.lblDescription.text = theCompany.Description;
cell.lblAddressPt1.text = theCompany.AddressPt1;
cell.lblAddressPt2.text = theCompany.AddressPt2;
cell.lblPhone.text = theCompany.Phone;
cell.lblEmail.text = theCompany.Email;
cell.lblDescription.adjustsFontSizeToFitWidth = false;
cell.lblDescription.lineBreakMode = UILineBreakModeWordWrap;
cell.lblDescription.numberOfLines = 0;
[cell.lblDescription sizeToFit];
NSURL *candidateURL = [NSURL URLWithString:theCompany.Url];
NSLog(@"%@", candidateURL);
if (!(candidateURL && candidateURL.scheme && candidateURL.host)) {
cell.lblTitle.textColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1];
}
return cell;
}
그리고 이것은 당신이 블랙 레이블이있는 셀을 큐에서 수도로, 명시 적으로 항상 cell.lblTitle.textColor을 설정해야 didSelectRowAtIndexPath
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
Company *company = [[Data getInstance].results objectAtIndex:indexPath.row];
NSURL *candidateURL = [NSURL URLWithString:company.Url];
if (candidateURL && candidateURL.scheme && candidateURL.host) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:company.Url]];
}
}
'candidateURL 속성 무엇인가 유효성을 테스트하는 값은 무엇입니까? 즉, 이것이 디스플레이 문제 또는 논리 문제입니까? – FluffulousChimp