在启动tableView时删除行查看

在启动tableView时删除行查看

问题描述:

如何在启动我的应用程序时在启动tableView期间删除行? 我tryed加activityIndi​​cator,但他不帮我。在启动tableView时删除行查看

可能是我在某种程度上设置不正确UIView还是需要使用别的东西?

可能是需要的代码activityIndi​​cator

private func setLoadingScreen() { 

    let width: CGFloat = 30 
    let height: CGFloat = 30 
    let x = (self.tableView.frame.width/2) - (width/2) 
    let y = (self.tableView.frame.height/2) - (height/2) - (self.navigationController?.navigationBar.frame.height)! 
    loadingView.frame = CGRect(x: x, y: y, width: width, height: height) 

    self.activityIndicator.activityIndicatorViewStyle = .gray 
    self.activityIndicator.frame = CGRect(x: 0, y: 0, width: 30, height: 30) 
    self.activityIndicator.startAnimating() 

    loadingView.addSubview(self.activityIndicator) 

    self.tableView.addSubview(self.loadingView) 

} 

private func removeLoadingScreen() { 

    self.activityIndicator.stopAnimating() 

} 

AI

+0

设置的tableview到UITableViewCellSeparatorStyleNone的separatorStyle。 –

+0

,因为我没有想过))谢谢:) –

最简单的解决方法是将一组负载之前UITableView定义为UITableViewCellSeparatorStyleNone的的separatorStyle属性的值。

self.tableView.separatorStyle = .none 

后装载完成后,你可以将其设置回UITableViewCellSeparatorStyleSingleLine

self.tableView.separatorStyle = .singleLine 

Apple Reference

设置空UITableView页脚。在这种情况下,您不必切换回separatorStyle。

self.tableView.tableFooterView = UIView() 

或设置UITableView分体样式.none

self.tableView.separatorStyle = .none 

我愿意为这样的创建UITableView扩展:

public extension UITableView { 
    /** 
    Hides the separators which display when the table view is empty. 
    */ 
    func hideSeparators() { 
     guard tableFooterView == nil else { return } 
     tableFooterView = UIView() 
    } 
}