Insert an image in a UITableView
  #1 (permalink)  
Unread 03-26-2009, 10:56 AM
Trust5 Trust5 is offline
Junior Member
 
Join Date: Mar 2009
Posts: 1
Smile Insert an image in a UITableView

Hi all,

I am beginner with Xcode and all the programming in Objective-C.
So, here is my problem:

I would like to insert an image in a cell of a UITableView instance. My application looks like that for now :



The image you can see has been implemented thanks to an UIImageView instance but it is static and what I want is that it moves when scrolling.


The code section where I want to insert an image is the following (in Bold):
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
	UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"TestCell"];
	if (cell == nil) {
		CGRect rect;
		rect = CGRectMake(0.0, 0.0, 320.0, 80.0);
		cell = [[[UITableViewCell alloc] initWithFrame:rect reuseIdentifier:@"TestCell"] autorelease];		
	}
/* DESCRIPTION */
/* Below, you have two switch levels. The first one deals with the section number and
the second with the row number. */
	{
		switch (indexPath.section) 
		{
				/* SECTION 0 */
			case 0:
				switch(indexPath.row)
			{
				case 0:
					//image = 
					break;
				case 1:
					cell.text = [NSString stringWithFormat:@"Tomb Raider - Underworld", indexPath.section, indexPath.row];
					return cell;
					break;
				default:
					cell.text = [NSString stringWithFormat:@"Empty cell", indexPath.section, indexPath.row];
					return cell;
					break;
			}

			...

			default:
				cell.text = [NSString stringWithFormat:@"Section %d", indexPath.section, indexPath.row];
				return cell;
				break;
		}
	}
}
I hope it is enough clear and that it is possible.

Thanks.
__________________
Jeremie
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT. The time now is 11:05 PM.


vBulletin skin developed by: eXtremepixels
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28