Tag: 可用

适用于iOS的Swift TableView

我提到了这个问题 ,并试图实现各种答案。 我正在做一些愚蠢的事情,因为cellForRow没有被调用,我只是得到一个空白的tableView。 是否有其他数据源或委托方法,我必须重写? 谢谢 class ViewController: UITableViewController { override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. //tableView.delegate = self //tableView.dataSource = self tableView.registerClass(UITableViewCell.classForCoder(), forCellReuseIdentifier: "Cell") //tableView.registerClass(MyTableViewCell.self, forCellReuseIdentifier: "Cell") tableView.reloadData() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. […]

UITableView设置背景颜色

我改变tableView:cellForRowAtIndexPath方法中的UITableViewCells的背景颜色 if(indexPath.row % 2 == 0){ cell.backgroundColor = … } else{ cell.backgroundColor = … } 但是,这只会改变tableView:numberOfRowsInSection中指定的单元格的颜色(如附图所示,前四个之后有白色单元格) 是否可以更改屏幕上显示的所有单元格的颜色?

UIRefreshControl与iOS7中的UICollectionView

在我的应用程序中,我使用集合视图的刷新控制。 UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:[UIScreen mainScreen].bounds]; collectionView.alwaysBounceVertical = YES; … [self.view addSubview:collectionView]; UIRefreshControl *refreshControl = [UIRefreshControl new]; [collectionView addSubview:refreshControl]; iOS7有一些令人讨厌的错误,当你拉取集合视图,并且在刷新开始时不松开你的手指时,垂直contentOffset向下移动20-30点,导致难看的滚动跳跃。 如果你在UITableViewController之外使用刷新控制,表格也有这个问题。 但对于他们来说,可以通过将UIRefreshControl实例分配给UITableView的私有属性_refreshControl来轻松解决: @interface UITableView () – (void)_setRefreshControl:(UIRefreshControl *)refreshControl; @end … UITableView *tableView = [[UITableView alloc] initWithFrame:[UIScreen mainScreen].bounds]; [self.view addSubview:tableView]; UIRefreshControl *refreshControl = [UIRefreshControl new]; [tableView addSubview:refreshControl]; [tableView _setRefreshControl:refreshControl]; 但是UICollectionView没有这样的属性,所以必须有一些手动处理它的方法。