开发者

Background image of selected cell

开发者 https://www.devze.com 2022-12-26 06:13 出处:网络
How to change cell background image on click on cell in iphone????I have tried following but it is not working....

How to change cell background image on click on cell in iphone????I have tried following but it is not working....

if (cell == nil) {
    开发者_运维问答cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0,0,320,50) reuseIdentifier:myid] autorelease];

    cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myImage.png"]];
}


cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myImage.png"]];

In the above piece of code you forget to autorelease; also have you set the delegate of the tableview? Set a breakpoint on the tableview:didselectRowAtIndexpath method to check if it is called or not.

BTW your code seems right.


You can change the selectionType of UITableView

using

cell.setSelectionStyle = [UITableViewSelectionStyleGray/Blue/None] (only 3 types)

some syntex error in above code try with proper syntex

by default it will be blue...


cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mImage.png"]]

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号