2013-05-23 1 views
0

Я пытаюсь использовать галочку в UITablewViewCell, которая является пользовательской ячейкой, которая имеет 3 метки. Проблема в том, что независимо от того, какое разрешение или размеры я использую для изображения галочки, он выглядит как пиксель, как на изображении ниже. Я пробовал 40x40, 60x60 и 80x80 пикселей, а также 72 Dpi и 300 Dpi без успеха. Вот код для пользовательской ячейки:UIImageView в пользовательских размерах и разрешении UITableCiewCell

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath 
    { 

     static NSString *CellIdentifier = @"MyCell"; 

    //UILabel *mainLabel, *secondLabel, *thirdLabel; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) 
{ 
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault  reuseIdentifier:CellIdentifier]; 

cell.accessoryType = UITableViewCellAccessoryNone; 


//Add the 3 labels 

mainLabel = [[UILabel alloc] initWithFrame:CGRectMake(40.0, 5.0, 180.0, 21.0)]; 
mainLabel.tag = MAINLABEL_TAG; 
//mainLabel.font = [UIFont systemFontOfSize:14.0]; 
//mainLabel.font = [UIFont fontWithName:@"Geeza Pro Bold" size:17.0]; 
mainLabel.font = [UIFont boldSystemFontOfSize:13]; 
mainLabel.textAlignment = UITextAlignmentLeft; 
mainLabel.textColor = [UIColor blackColor]; 
mainLabel.highlightedTextColor = [UIColor whiteColor]; 
mainLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 
[cell.contentView addSubview:mainLabel]; 

secondLabel = [[UILabel alloc] initWithFrame:CGRectMake(40.0, 21.0, 190.0, 21.0)]; 
secondLabel.tag = SECONDLABEL_TAG; 
//secondLabel.font = [UIFont systemFontOfSize:12.0]; 
//secondLabel.font = [UIFont fontWithName:@"Geeza Pro" size:15.0]; 
secondLabel.font = [UIFont systemFontOfSize:13]; 
secondLabel.textAlignment = UITextAlignmentLeft; 
secondLabel.textColor = [UIColor darkGrayColor]; 
secondLabel.highlightedTextColor = [UIColor whiteColor]; 
secondLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 
[cell.contentView addSubview:secondLabel]; 

thirdLabel = [[UILabel alloc] initWithFrame:CGRectMake(240.0, 11.0, 70.0, 21.0)]; 
thirdLabel.tag = THIRDLABEL_TAG; 
//thirdLabel.font = [UIFont systemFontOfSize:12.0]; 
//thirdLabel.font = [UIFont fontWithName:@"Geeza Pro Bold" size:17.0]; 
thirdLabel.font = [UIFont boldSystemFontOfSize:13]; 
thirdLabel.textAlignment = UITextAlignmentRight; 
thirdLabel.textColor = [UIColor blackColor]; 
thirdLabel.highlightedTextColor = [UIColor whiteColor]; 
thirdLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 
[cell.contentView addSubview:thirdLabel]; 


} 
    else 
    { 
     mainLabel = (UILabel *)[cell.contentView viewWithTag:MAINLABEL_TAG]; 
     secondLabel = (UILabel *)[cell.contentView viewWithTag:SECONDLABEL_TAG]; 
     thirdLabel = (UILabel *)[cell.contentView viewWithTag:THIRDLABEL_TAG]; 
    } 

//If the requesting table view is the search display controller's table view, configure the cell using the filtered content, otherwise use the main list. 

Car *car = nil; 
if (tableView == self.searchDisplayController.searchResultsTableView) 
{ 
    car = [self.filteredListContent objectAtIndex:indexPath.row]; 
} 
else 
{ 
     car = [self.listContent objectAtIndex:indexPath.row]; 
    } 


NSString *carName = [NSString stringWithFormat:@"%@",car.deviceName]; 
NSString *carDetails = [NSString stringWithFormat:@"%@ at %@",car.date,car.location]; 
NSString *carSpeed = [NSString stringWithFormat:@"%@ km/h",car.speed]; 


mainLabel.text = carName; 
secondLabel.text = carDetails; 
thirdLabel.text = carSpeed; 

//Check for selection 
if (car.isSelected == YES) 
{ 
    [cell.imageView setImage:[UIImage imageNamed:@"new_checkmark.png"]]; 
} 
else 
{ 
    [cell.imageView setImage:nil]; 
} 

return cell; 
} 

А вот снимок экрана: enter image description here

+0

Вы используете сетчатку изображение для сетчатки дисплеев? например, должно быть два изображения «new_checkmark.png» для не сетчатки и «[email protected]» для устройств сетчатки. А также вы должны установить рамку UIImageView пропорционально размеру изображения. – cekisakurek

ответ

1

создать два изображения с именем new_checkmark.png & [email protected]

новый[email protected] должен быть удвоен размер new_checkmark.png пропорционально.

в кодировании расширения использования не делает, onlu дать имя как этот

[cell.imageView setImage:[UIImage imageNamed:@"new_checkmark"]]; 
+0

Спасибо. Теперь это выглядит хорошо. – Ali

 Смежные вопросы

  • Нет связанных вопросов^_^