Skip to content

Instantly share code, notes, and snippets.

@anujb
Created October 18, 2011 03:22
Show Gist options
  • Save anujb/1294537 to your computer and use it in GitHub Desktop.
Save anujb/1294537 to your computer and use it in GitHub Desktop.
hide browser action example
using System.Collections.Generic;
namespace SozoChildrenInternational
{
public partial class FirstViewController : UIViewController
{
Action HideBrowserAction;
public FirstViewController () : base ("FirstViewController", null)
{
TabBarItem.Title = "About";
TabBarItem.Image = UIImage.FromBundle ("Images/first");
HideBrowserAction = HandleHideBrowserAction;
}
public void HandleHideBrowserAction()
{
//Hide your browsers hide your pickers, they picking errbody up in hurrr..
}
public override void DidReceiveMemoryWarning ()
{
// Releases the view if it doesn't have a superview.
base.DidReceiveMemoryWarning ();
// Release any cached data, images, etc that aren't in use.
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Hide our picker
AboutPicker.Hidden = true;
// Wire up our picker
AboutPicker.Model = new PickerView();
AboutPicker.ShowSelectionIndicator = true;
AboutPicker.HideBrowser = this.HideBrowserAction;
// Change titles
MoreButton.Title = "More";
NavigationBar.TopItem.Title = "About Sozo";
//Wire up our web browser
NSUrl AboutSozo = NSUrl.FromFilename ("HTML/AboutSozo.html");
NSUrlRequest request = new NSUrlRequest(AboutSozo);
WebBrowser.LoadRequest(request);
WebBrowser.ScalesPageToFit = false;
//Wire up our MoreButton
MoreButton.Clicked += delegate {
AboutPicker.Hidden = false;
};
}
public override void ViewDidUnload ()
{
base.ViewDidUnload ();
// Release any retained subviews of the main view.
// e.g. myOutlet = null;
}
public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
{
// Return true for supported orientations
return (toInterfaceOrientation != UIInterfaceOrientation.PortraitUpsideDown);
}
public class PickerView : UIPickerViewModel
{
List<string> PickerData;
public Action HideBrowser { get; set; }
public PickerView()
{
PickerData = new List<string> {"Our Story", "Our Vision", "Our Future", "Our Team", "Our Partners", "Goals & Objectives"};
}
public override int GetComponentCount (UIPickerView picker)
{
return 1;
}
public override int GetRowsInComponent (UIPickerView picker, int component)
{
return PickerData.Count;
}
public override string GetTitle (UIPickerView picker, int row, int component)
{
return PickerData[row];
}
public override void Selected (UIPickerView picker, int row, int component)
{
// Add support so the picker disappears and the correct local HTML content is displayed
if(HideBrowser != null)
HideBrowser();
picker.Hidden = true;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment