display a bg image in table view for iphone - iphone

i can display BG image in table view cell but when i click any cell there is a blue color filling all my cell and my images just goes behind now i want to show my image in front of that blue color how to do that??
cell.backgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:#"SuperCell.png"]] autorelease];

Maybe you can use
cell.selectionStyle = UITableViewCellSelectionStyleNone;
and
cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:#"SuperCell.png"]] autorelease];

Related

Animate iphone tableviewCell background image with two images

i want to animate tableviewcell background image with two blinking images on didSelectRowAtIndexPath. We can use following code, but it will show one image in background. However I want gif like image which blinks.
cell.backgroundView = [ [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"correctAnswer.png"]]autorelease];
UIImageView has the ability to do animation with the animationImages property.
UIImageView* imgView = [[[UIImageView alloc] init] autorelease];
imgView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:#"correctAnswer1.png"],
[UIImage imageNamed:#"correctAnswer2.png"], nil];
imgView.animationDuration = 0.5;
cell.backgroundView = imgView;
[imgView startAnimating];
You need to have each frame of the animation included in your project, correctAnswer1.png, correctAnswer2.png, etc...
Also, wouldn't it be better to use UITableViewCell's imageView property? That way you would get your animation in the left of the cell and it wouldn't interfere with the text or any other parts of the cell...

How to make semi-transparent UITableViewCells?

I hope to add image to cell background and from the semi transparent cell I could see the backgroud of tableview.
From following topic, I know how to make transparent cell.
UITableViewCell transparent background (including imageView/accessoryView)
I've tried above, it did work. But when I add the following code:
UIView *backView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
backView.backgroundColor = [UIColor colorWithRed:.1 green:.1 blue:.1 alpha: .4];
cell.backgroundView = backView;
The cell became grey color without any transparency, if I change code as follows,
UIView *backView = [[UIView alloc] initWithFrame:CGRectZero];
backView.backgroundColor = [UIColor clearColor];
cell.backgroundView = backView;
The cell became white, still without any transparency.
Is there one can give me any clues?
To make your UITableViewCells Semi-Transparent that is Translucent, you have to make your UITableViewCells Transparent and then, set cell's backgroundView to an image which has translucent properties. Also set selectedBackgroundView of the cell to an image which is translucent and gives a selected cell's effect.
UIView *backView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
backView.backgroundColor = [UIColor clearColor];
cell.text.backroundColor = [UIColor clearColor]; //if you have labels on cells..
cell.backgroundView = backView;
Then set an image with translucent effect on our transparent cell..
UIImageView *cellImage = [[UIImageView alloc] init];
[cellImage setImage:[UIImage imageNamed: #"unselectedCellImage.png"]];
[cell setBackgroundView:cellImage];
[cellImage release];
Then set an image for selected cell to give an translucent effect after selection also..
UIImageView *cellImageSelection = [[UIImageView alloc] init];
[cellImageSelection setImage:[UIImage imageNamed: #"selectedCellImage.png"]];
[cell setSelectedBackgroundView:cellImageSelection];
[cellImageSelection release];
It'll work..
Cheers..
You can try this one
UIView *backView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
backView.backgroundColor = [UIColor colorWithRed:255 green:255 blue:255 alpha: .2];
cell.backgroundView = backView;
What you did wrong was you choose .1 .1 .1 which is for black color you need 255 255 255 for the white color and your opacity was very high so it looked gray color to you actually it was black with opacity. Hope this helps :)
Views are initialized as opaque by default, so you probably need to explicitly set backView.opaque = NO; in order for it to draw with any transparency.

change table view's cell selection color

can we change the selection color of table view, i.e cell, by default its blue, so, can we change it to any other color?
regards
this way in code
aCell.selectedBackgroundView = [[[UIImageView alloc]
initWithImage:[UIImage imageNamed:#"selectedBackground.png"]] autorelease];
or you can set it in interface builder to gray, I think blue and grey is all that is available without creating a be view
Another way to do this, that doesn't require an image file is:
UIView *bgView = [[UIView alloc] init];
// At least on iOS6 you don't to size the view for this to work.
bgView.backgroundColor = [UIColor grayColor];
aCell.selectedBackgroundView = bgView;

Background image of selected cell

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"]]

How to remove the white background of UITableViewCell

I want to remove the default white background of UITableViewCell like I want the background of the cell being transparent so that it shows the actual background of the window.
I Got it.
UIView *backView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
backView.backgroundColor = [UIColor clearColor];
cell.backgroundView = backView;