我是iOS開發的初學者。我面臨一個問題,我需要一點幫助。爲什麼UITableViewCell在滑動視圖時改變了它的大小
我寫了一個小程序來學習自定義的UITableViewCell。它剛開始時效果很好;之後,當我滑動視圖時,它會更改單元格的大小。我對我可能會出錯的地方感到困惑。 ContentView只有一個視圖是UIImageView。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
HWHomePageCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HWHomePageCell"];
if (cell == nil)
{
cell = [HWHomePageCell homePageCell];
}
cell.imageView.image = [UIImage imageNamed:@"XD"];
return cell;
}
您可能需要添加cell.imageView.contentMode = UIViewContentModeScaleAspectFill;以下鏈接可能有幫助。 http://stackoverflow.com/questions/6638623/uiviewcontentmodescaleaspectfill-not-clipping –