0

Tried below properties but didn't work like I need :

this.TableView.ContentInset this.TableView.ContentOffset

Basically, I have image header at the very top of the uitableviewcontroller , so when tableview gets populated , header image is laid over by cells ...plz look at the image

enter image description here

Eventually, I want to shift cells a little down to leave room for the title image.


update :

added this code and somehow worked

UIImageView img = new UIImageView (new RectangleF ((this.View.Bounds.Width- 164)/2,0, 164, 44));
img.Image = UIImage.FromFile ("Images/app-name.png");
this.TableView.TableHeaderView(img);

enter image description here

but the image is stretched out

user427969
  • 3,836
  • 6
  • 50
  • 75
Pirate
  • 71
  • 1
  • 10

1 Answers1

1

Add your image in table header tableHeaderView.

Also, set custom height to the table header - sectionHeaderHeight:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableView_Class/Reference/Reference.html

Note: these are UITableView class's properties. I am not sure about Monotouch but you might be able to find some similar properties in it.


Please try any of the following:

Refer to this answer and its comments: Adding an image to a Section in Monotouch.Dialog

HeaderView = new UIImageView (UIImage.FromFile ("imagename.png"))

Or refer to this : http://dantes-andreea.blogspot.com.au/2011/08/monotouch-class-for-resize-maintaining.html


Try this : iphone: put uiimage in tableview section header, stretch problem

Community
  • 1
  • 1
user427969
  • 3,836
  • 6
  • 50
  • 75
  • Could you please update your code in question? Its hard to read here. It would also be better if you could add screenshot of that. – user427969 Oct 24 '12 at 21:59
  • If that's a static image then you could add it in Storyboard or Interface builder or your designer – user427969 Oct 24 '12 at 22:01
  • You can't add code in comments! Edit your question and add your code there. I am not an expert with Monotouch but I think there might be some size issue with `RectangleF` – user427969 Oct 24 '12 at 22:07
  • May be try to find how to set the size for `RectangleF`. Also, try to set the image in your designer. – user427969 Oct 24 '12 at 22:10
  • the image is exactly the same size and location on 3 other views . If you see the first image , it's actually the same one with same dimensions ! – Pirate Oct 24 '12 at 22:13
  • i even set width to 40 instead of 164 but didn't change the size ! – Pirate Oct 24 '12 at 22:19
  • What is your image's size - width x height ? – user427969 Oct 24 '12 at 22:20
  • width = 164 , height = 44 ...i tried this UIImageView img = new UIImageView (new RectangleF (0,0, 10, 44)); but didn't work ...size doesn't get changed – Pirate Oct 24 '12 at 22:27
  • Sorry man , didn't work ...and also i'm not using Monotouch.Dialog so i can try that code ...any other thoughts ?? – Pirate Oct 24 '12 at 23:30
  • I have added another link in my answer – user427969 Oct 24 '12 at 23:41
  • hey man , sorry to sound dumb ! i tried the solution in the link you posted , and i hope i translated the code right but it didn't have any effect ...I'm doing that in the ViewDidLoad event ...any thoughts ! – Pirate Oct 25 '12 at 19:16
  • Ok , it's fixed now ..i used trick here : http://stackoverflow.com/questions/7841167/table-header-views-in-storyboards ...... thanks a lot for your time – Pirate Oct 25 '12 at 19:48