【发布时间】:2014-01-21 00:28:32
【问题描述】:
我想用滑块更改 uicollectionview 中单元格的大小,但我找不到怎么做。
当您看到图标时,就像在 macOS 查找器中一样,您可以使用滑块更改其大小。
我想要它用于 iPad 应用程序
【问题讨论】:
-
你有没有尝试过?
我想用滑块更改 uicollectionview 中单元格的大小,但我找不到怎么做。
当您看到图标时,就像在 macOS 查找器中一样,您可以使用滑块更改其大小。
我想要它用于 iPad 应用程序
【问题讨论】:
- (IBAction)sliderChanged:(id)sender {
[self.tableView reloadData];
}
将您的滑块连接到上述方法(用于更改值),然后使用以下方法定义高度:
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:
(NSIndexPath *)indexPath {
return self.slider.value;
}
【讨论】:
几乎完美,我想要一个 uicollection 视图,所以我需要更改:
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
{
//Return the size of each cell to draw
CGSize cellSize = (CGSize) { .width = 320, .height = self.slider.value};
return cellSize;
}
【讨论】: