In My Application I have to show Image after every 3 Rows.My Image is static and it should come after every 3 rows.I don't want to take UIImageView and add it to cell but if there any way to show my image using directly Cell's property.My Image size is 320X87 pixels.
A:
I don't believe this is possible, as your image is far too large for a standard UITableViewCell. You will need to make a custom cell, and then load the appropriate cell in the cellForRowAtIndex method. Don't forget to set the appropriate cellIdentifiers in your code/IB.
Maybe you could possibly add a UIImageView as a subview of a standard cell's contentView, but this doesn't sound like the best solution to me.
alku83
2010-05-11 07:12:16
Actually i know it is possible because in Tableview's - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPathin this method by writing this code we can do it but i just want set the Frame of the cell for that Image cell.image=[UIImage imageNamed:@"abc.png"];but this code can't set the actual Image size for cell if you how to set Cell Frame for Image then please Tell me. and Thanks for Reply.
Ankit Vyas
2010-05-11 07:19:34
I don't believe you can change the frame size of a standard UITableViewCell. Thomas Joulin's code sample is the best option.
alku83
2010-05-11 07:26:02
+1
A:
You would have to create a custom cell for this specific cell, but it will be instanciated once, thanks to reusableCells. For instance :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"TableCell";
static NSString *ImageIdentifier = @"ImageCell";
UITableViewCell *cell;
if (!(indexPath.row % 3))
{
cell = [tableView dequeueReusableCellWithIdentifier:ImageIdentifier];
if (cell == nil)
{
cell = [[[MyCustomCell alloc] initWithDelegate:self reuseIdentifier:(NSString *)ImageIdentifier] autorelease];
}
}
else
{
cell = [tableView dequeueReusableCellWithIdentifier:ImageIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithDelegate:self reuseIdentifier:(NSString *)ImageIdentifier] autorelease];
}
// customization of your rows here (title, ...)
}
return cell;
}
Thomas Joulin
2010-05-11 07:19:06
Thanks Man!But i have used Different Option.You are Perfectly correct.No issues with your code.Thanks again.
Ankit Vyas
2010-05-11 11:04:07
A:
Just make a cell of sufficient height with the appropriate delegate method, then add your image view as a subview to the cell's contentView
property.
Alex Reynolds
2010-05-11 07:19:17