2015-08-24 5 views
1

Проверьте ссылку, прилагаемую к ссылке. Линия между первыми двумя ячейками имеет отступ, но линия между двумя нижними ячейками проходит полностью. Первые две ячейки - это отдельный раздел, чем нижняя ячейка (так что есть 2 раздела, предыдущий кодер установил его таким образом, и так оно и должно быть ...). Я пытаюсь получить линию между двумя нижними ячейками так же, как линия между двумя первыми (отступом). Какой был бы лучший способ сделать это? Pic прилагаетсяРедактировать строки между ячейками?

здесь метод cellForRowAtIndexPath:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    static NSString *CellIdentifier = @"InAppPurchaseViewCellIdentifer"; 
    // InAppPurchaseViewCell *cell = (InAppPurchaseViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 
    InAppPurchaseViewCell *cell = (InAppPurchaseViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    NSArray *currentSectionArray = nil; 

    switch (indexPath.section) { 
     case 0: 
      currentSectionArray = _productGroupZeroArray; 
      break; 
     case 1: 
      currentSectionArray = _productGroupOneArray; 
      break; 
     case 2: 
      currentSectionArray = _productGroupTwoArray; 
      break; 
     case 3: 
      currentSectionArray = _productGroupThreeArray; 
      break; 
     default: 
      break; 
    } 

    NSDictionary *currentProductDictionary = [currentSectionArray objectAtIndex:indexPath.row]; 
    NSString *currentProductIdString = [currentProductDictionary objectForKey:kInAppOptionProductID]; 

    __block SKProduct *currentProduct = nil; 

    [_skProductArray enumerateObjectsUsingBlock:^(SKProduct *product, NSUInteger idx, BOOL *stop) { 
     if ([product.productIdentifier isEqualToString:currentProductIdString]) { 
      currentProduct = product; 
      *stop = YES; 
     } 
    }]; 

    if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) { 
     cell.productNameLabel.backgroundColor = [UIColor groupTableViewBackgroundColor]; 
     cell.backgroundColor = [UIColor groupTableViewBackgroundColor]; 
     cell.productNameLabel.textColor = [UIColor darkGrayColor]; 
     cell.priceLabel.backgroundColor = [UIColor colorWithRed:249.0/255.0 green:198.0/255.0 blue:6.0/255.0 alpha:1.0]; 
     cell.priceLabel.textColor = [UIColor whiteColor]; 
    } else { 
     cell.productNameLabel.backgroundColor = [UIColor groupTableViewBackgroundColor]; 
     cell.backgroundColor = [UIColor groupTableViewBackgroundColor]; 
     cell.productNameLabel.textColor = [UIColor darkGrayColor]; 
     cell.priceLabel.backgroundColor = [UIColor colorWithRed:249.0/255.0 green:198.0/255.0 blue:6.0/255.0 alpha:1.0]; 
     cell.priceLabel.textColor = [UIColor whiteColor]; 
    } 

    cell.userInteractionEnabled = YES; 

    if ([[InAppPurchaseHelper sharedInstance] productPurchased:currentProduct.productIdentifier]) { 
     if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) { 
      cell.priceLabel.textColor = [UIColor colorWithRed:0.0 green:0.576 blue:0.0 alpha:1.0]; 
     } else { 
      cell.priceLabel.backgroundColor = [UIColor colorWithRed:0.0 green:0.576 blue:0.0 alpha:1.0]; 
     } 
     cell.priceLabel.text = @"Paid"; 
     cell.userInteractionEnabled = YES; 
    } else { 
     [_priceFormatter setLocale:currentProduct.priceLocale]; 
     NSString *priceString = [_priceFormatter stringFromNumber:currentProduct.price]; 
     cell.priceLabel.text = priceString; 
    } 

    cell.frame = CGRectOffset(cell.frame, 10, 10); 

    if (currentSectionArray == _productGroupZeroArray) { 
     cell.productNameLabel.text = [tableData objectAtIndex:indexPath.row]; 
    }else if (currentSectionArray == _productGroupOneArray) { 
     cell.productNameLabel.text = @"Annual Subscription:\nTestBank for every exam!"; 
    } 

    return cell; 
} 

enter image description here

+0

Добавить код таблицы. –

+0

Лучший способ - сделать свой собственный разделитель с UIView высотой 1 ... полностью настраиваемый ... (так что вы также можете скрыть последний разделитель) – altagir

ответ

0

попробовать:

[tableView setSeparatorInset:UIEdgeInsetsMake(spaceValue, 0, 0, 0)]; 

Надеюсь, что это может помочь.

+0

В viewDidLoad? – MrDevRI

+0

да, это может быть приятно. После того, как вы запустили 'tableview'. –

+0

Я использовал его в viewDidLoad, но ничего не изменил: / – MrDevRI

0

Tableview сепаратор между секций отличается от клеток сепаратора в пределах секции.

Вы можете

  • разделитель изменения врезка первой ячейки, чтобы соответствовать разделу сепаратора или

  • обновить код, чтобы сгруппировать все ячейки в одной и тот же разделе .

Я понимаю, что вы не хотите делать ни один, но это работает в пределах того, что поддерживает Apple. В противном случае вам, возможно, придется скрывать разделитель Apple и нарисовать свой собственный.

0

Может быть, вы можете попробовать это

-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ 
// Remove seperator inset 
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) { 
     [cell setSeparatorInset:UIEdgeInsetsZero]; 
} 

// Prevent the cell from inheriting the Table View's margin settings 
if ([cell respondsToSelector:@selector(setPreservesSuperviewLayoutMargins:)]) { 
    [cell setPreservesSuperviewLayoutMargins:NO]; 
} 

// Explictly set your cell's layout margins 
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) { 
    [cell setLayoutMargins:UIEdgeInsetsZero]; 
}} 

Надеется, что это может помочь вам.

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