MonoTouch UITableViewController and TableFooterView?

You can add subviews like this ,sbar is the search bar,u can also add any controllers like button ,labels ,textview,textfield in it.

Up vote 2 down vote favorite 1 share g+ share fb share tw.

I'm trying to develop a small iPhone application using MonoDevelop (v2.8) and MonoTouch (v4.2.2). My home screen is represented by a UITableViewController which use a UITableView for presentation. I want to fill the UITableView.

TableFooterView (which is a UIView object) with some other controls (two labels and two buttons). To do this I have created a "subview" called SearchView, which is represented by a UIViewController and use a simple UIView for presentation. I assign this view as footer view of the tableview.

Public partial class HomeScreen : UITableViewController { public override void ViewDidLoad() { base.ViewDidLoad(); SearchViewController searchViewController = new SearchViewController(); this.TableView. TableFooterView = searchViewController. View; } } Is this right?

It is right to assume that usaually you create a view (UIView) and consume it by a UIViewController? Iphone mono uikit monotouch monodevelop link|improve this question asked Oct 29 '11 at 10:07John1587 80% accept rate.

You can run into issues with the above code (unrelated to your question) since searchViewController if a local variable and no reference to it will exists when ViewDidLoad return (the View will be referenced, not the controller). That makes it possible for the GC to collect searchViewController which can crash your application. The easiest way to avoid this is promoting your variable into a field (so a reference will exist once the method return).

– poupou Oct 29 '11 at 14:00 Thanks poupuo. I'am already aware of this. I have put the declaration in the method just to make things understandable.

I also know that this issue will be resolved in the near future by the monotouch team. Any hint about my question? – John Oct 29 '11 at 16:58.

(void)loadView { super loadView; sBar = UISearchBar allocinitWithFrame:CGRectMake(0,0,320,30); sBar. Delegate = self; self. View addSubview:sBar; you can add subviews like this ,sbar is the search bar,u can also add any controllers like button ,labels ,textview,textfield in it.

Yes I Know, but when the UITableViewController is created the this.TableView. TableFooterView property is null, so I can't do this.TableView.TableFooterView.AddSubView. I can't also add subview to the TableView (this.TableView.

AddSubView) beacuse it renders wired things. – John Oct 29 '11 at 11:35.

In your UITableViewDataSource you can override public virtual UIView GetViewForFooter(UITableView tableView, int sectionIndex) public override UIView GetViewForFooter(UITableView tableView, int sectionIndex) { // Write a method to get the proper Section via the sectionIndex var section = GetSection(sectionIndex); if (section! = null) { if (section. FooterView == null &&!string.

IsNullOrEmpty(section. FooterText)) { // Create your FooterView here section. FooterView = CreateFooterView(tableView, section.

FooterText); } return section. FooterView; } return null; } As of iOS 5 you will also need to override public virtual float GetHeightForFooter(UITableView tableView, int sectionIndex) and return the height of the FooterView.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions