[英]How to set the background image for last cell and find the table view height in iPhone?
[英]How do I set background image in the table view cell in iPhone
我想為單元格設置背景圖像。 我已經在表格視圖中為單元格設置了背景圖像。 但是我想在表格視圖單元格中為背景圖像設置兩個圖像。 我想為背景設置備用單元格,
喜歡,
Image1- Cell 1, Cell 3, Cell 5, Etc.,
Imgae-2- Cell 2, Cell 4,Cell 6, Etc.,
請指導我並給我一些示例鏈接。
謝謝!
您可以為下面的偶數/不均勻行設置兩個不同的單元格
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifierEvenRows = @"MyCellEven";
static NSString *CellIdentifierUnevenRows = @"MyCellUneven";
UITableViewCell *cell;
if (indexPath.row % 2) {
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierUnevenRows];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifierUnevenRows] autorelease];
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"uneven.png"] autorelease];
}
} else {
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifierEvenRows];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifierEvenRows] autorelease];
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"even.png"] autorelease];
}
}
return cell;
}
(雖未測試)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.