UITableViewCell自定义缩进宽度

时间:2015-07-20 02:45:36

标签: ios swift uitableview uidevice

我的应用包含UITableViewController。默认缩进(编辑时)很好,除非在横向模式下的iPad上,当缩进太宽时。我已尝试在indentationWidth中设置indentationLevelcellForRowAtIndexPath,但似乎没有任何效果。

我希望我的代码可以像这样工作:

override func tableView(tableView: UITableView, 
  cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell 
{
    let cell = tableView.dequeueReusableCellWithIdentifier("Cell",
                                                           forIndexPath: indexPath)

    // do other cell configuration here
    if UIDevice.currentDevice().userInterfaceIdiom == .Pad {
        // set the custom indentation level for the cell here
        // Tried:
        // cell.indentationWidth = 0.1
        // cell.indentationLevel = 0
        // both have absolutely no effect
    }
}

iPad在风景中的可怕缩进: editing 未编辑的相同单元格: not editing 提前感谢您的帮助。

1 个答案:

答案 0 :(得分:2)

在viewDidLoad中,添加以下行:

var elem = document.querySelector('.wrap');
var $elem = angular.element(elem);

var slides = [
  { color: "#f00" },
  { color: "#0f0" },
  { color: "#00f" },
];

var current = 0;
$scope.slide = slides[ current ];

// switch to next slide
$scope.nextSlide = function(){
  $elem.removeClass('animate-back');
  if(slides.length <= ++current){
    current = 0;
  }
  $scope.slide = slides[ current ];
};

// switch to prev slide
$scope.prevSlide = function(){
  $elem.addClass('animate-back');
  if(--current<0){
    current = slides.length-1;
  }
  $scope.slide = slides[ current ];
};

默认设置为YES,这会在较新的iPad上产生横向边距。