我正在研究一個應用程序,其中包含一些顯示相冊列表的功能。我使用香草UITableView
和香草UITableViewCell
s。我正在使用Subtitle
款式UITableViewCell
並在cell.imageView.image
上設置縮略圖。注意:這不是自定義單元格,而是內置單元格imageView。UITableViewCell圖像在選擇時會變大放大
問題是,當我點擊一個單元格時,imageView變得更大,這看起來很奇怪,因爲a)這不是直觀的行爲,b)它不再與其他每行相匹配。
的選擇之前,細胞的ImageView的框架是:
cell.imageView.frame: {{16, 1}, {84, 84}}
選擇後,這些細胞的ImageView的框架是:
cell.imageView.frame: {{16, 0}, {88, 87.5}}
我沒有參與任何代碼,這是一個香草UITableViewCell。
我有一個唯一的代碼與ImageView的相互作用是我用來獲取照片資產和更新單元格的PhotoKit代碼:
PHImageRequestOptions *options = [[PHImageRequestOptions alloc] init];
options.resizeMode = PHImageRequestOptionsResizeModeExact;
[self.imageManager requestImageForAsset:asset
targetSize:AssetGridThumbnailSize
contentMode:PHImageContentModeAspectFill
options:options
resultHandler:^(UIImage *result, NSDictionary *info) {
// Only update the thumbnail if the cell tag hasn't changed.
// Otherwise, the cell has been re-used.
if (cell.tag == currentTag) {
cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
cell.imageView.image = result;
}
}];
這究竟是爲什麼?我怎樣才能阻止它?
我認爲你的tableView的'heightForRowAtIndex:'方法返回的值比單元格的高度要小。要測試它是否正常工作,請從此方法返回一些重要的大值。 – Shamsiddin