0
UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 30, 50)];
[imageView setImage:[UIImage imageNamed:@"111-user.png"]];
[tableView setTableHeaderView:imageView];
[imageView release];

Can anybody tell me how can i put the second image in setTableHeaderView?

Jacob Relkin
  • 161,348
  • 33
  • 346
  • 320
RAMAN RANA
  • 1,785
  • 4
  • 21
  • 40

2 Answers2

1

Create a new UIView which will contain both UIImageView instances:

UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(...)];
UIImageView *firstImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 30, 50)];
[firstImageView setImage:[UIImage imageNamed:@"111-user.png"]];
[headerView addSubview:firstImageView];
[imageView release];
//do same thing with another UIImageView...
[tableView setTableHeaderView:headerView];
[headerView release];
Jacob Relkin
  • 161,348
  • 33
  • 346
  • 320
  • [UIImage imageNamed:@"111-user.png"] this is wrong method to hold a image in image view it store image in cache memory and it give memory waring if your project if big – GhostRider Dec 08 '10 at 04:50
  • @GhostRider, I beg your pardon? – Jacob Relkin Dec 08 '10 at 04:51
  • [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"DOT" ofType:@"png"]] always hold image in this formate that will not store in your phone cache memeory – GhostRider Dec 08 '10 at 04:53
  • @GhostRider, Why *wouldn't* the OP want this? – Jacob Relkin Dec 08 '10 at 04:54
  • I actually think @GhostRider has got a point. I always had issues with imageNamed not freeing up memory allocated for images and read somewhere that pathForResource:ofType: is more efficient. Haven't done any tests to confirm it though. – Rog Dec 08 '10 at 04:55
  • Quick search and here's a code SO discussion on the issue http://stackoverflow.com/questions/924740/dispelling-the-uiimage-imagenamed-fud – Rog Dec 08 '10 at 04:57
  • when you make a large size project then you got memory waring if you use this type [UIImage imageNamed:@"111-user.png"] so – GhostRider Dec 08 '10 at 04:57
  • @GhostRider Depends which OS version it is, but nevertheless you make a good point. – Jacob Relkin Dec 08 '10 at 04:58
  • @RAMAN RANA :Thats what jacob has replied to.... please see the comment also which says do the same for image 2 – Suresh Varma Dec 08 '10 at 05:48
0

Create a UIView with your 2 UIImageViews and add the UIView to the tableHeaderView.

[EDIT]

Since you are still having problems I've done a quick test project so you can see how it works. You can download it from here http://bit.ly/fvJgiz

Rog
  • 18,602
  • 6
  • 76
  • 97