Open psmds opened 9 years ago
I have the same problem. Once I login, and as i click on flyout button to navigate it shows me nullReferanceException.
Can anybody suggest the solution for this.
How you are adding flyout button? May be your flyout button will be null or your flyout navigation controller object will be null i.e yourflyoutobject.ToggleMenu() may be cause for null reference exception
Can you post your code(flyout part)?
using System; using System.Linq; using System.Collections.Generic;
using UIKit; using Foundation;
using MonoTouch.Foundation; using MonoTouch.UIKit;
using MonoTouch.Dialog; using FlyoutNavigation;
namespace GoodTVIOS { public class MainController : UIViewController { FlyoutNavigationController navigation;
// // Data we'll use to create our flyout menu and views: string[] Tasks = { "Get Xamarin", "Learn C#", "Write Killer App", "Add Platforms", "Profit", "Meet Obama", };
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Create the flyout view controller, make it large,
// and add it as a subview:
navigation = new FlyoutNavigationController ();
navigation.Position = FlyOutNavigationPosition.Right;
navigation.View.Frame = UIScreen.MainScreen.Bounds;
View.AddSubview (navigation.View);
this.AddChildViewController (navigation);
// Create the menu:
navigation.NavigationRoot = new RootElement ("Extras") {
new Section ("Task List") {
from page in Tasks
select new StringElement (page) as Element
},
new Section ("Extras")
{
new BooleanElement("Toggle",true),
new StringElement("Home Page"),
new StringElement("Search"),
//new BooleanElement("Toggle",true),
//new StringElement("Profile"),
//new StringElement("Swipable Table"),
}
};
// Create an array of UINavigationControllers that correspond to your
// menu items:
var viewControllers = Tasks.Select (x => new UINavigationController (new TaskPageController (navigation, x))).ToList ();
//Load from Storyboard
var storyboardVc = CreateViewController<MyStoryboardViewController> ("MyStoryBoard", "MyStoryboardViewController");
storyboardVc.navigation = navigation;
viewControllers.Add (new UINavigationController(storyboardVc));
//Add null for the toggle switch
//viewControllers.Add (null);
// var ChannelVc = CreateViewController
// viewControllers.Add (new UINavigationController(new SwipableTableView ()));
var HomePVC = CreateViewController<HomePageViewController> ("MyStoryBoard", "HomePageViewController");
HomePVC.navigation = navigation;
viewControllers.Add (new UINavigationController (HomePVC));
var SearchPVC = CreateViewController<SearchPageViewController> ("MyStoryBoard", "SearchPageViewController");
SearchPVC.navigation = navigation;
viewControllers.Add (new UINavigationController (SearchPVC));
navigation.ViewControllers = viewControllers.ToArray ();
}
static T CreateViewController<T>(string storyboardName, string viewControllerStoryBoardId = "") where T : UIViewController
{
var storyboard = UIStoryboard.FromName (storyboardName,null);
return string.IsNullOrEmpty(viewControllerStoryBoardId) ? (T)storyboard.InstantiateInitialViewController () : (T) storyboard.InstantiateViewController(viewControllerStoryBoardId);
}
class TaskPageController : DialogViewController
{
public TaskPageController (FlyoutNavigationController navigation, string title) : base (null)
{
Root = new RootElement (title) {
new Section {
new CheckboxElement (title)
}
};
NavigationItem.LeftBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Action, delegate {
navigation.ToggleMenu ();
});
}
}
}
}
$$HomePageViewController.cs
using Foundation; using System; using System.CodeDom.Compiler; using UIKit; using FlyoutNavigation; namespace GoodTVIOS { partial class HomePageViewController : UIViewController { public FlyoutNavigationController navigation { get; set; } public HomePageViewController (IntPtr handle) : base (handle) { }
public HomePageViewController()
{
NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, delegate
{
navigation.ToggleMenu();
});
}
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, delegate
{
navigation.ToggleMenu();
});
}
}
}
$$AppDelegates.cs
using System; using System.Linq; using System.Collections.Generic;
using UIKit; using Foundation;
using MonoTouch.Foundation; using MonoTouch.UIKit;
using MonoTouch.Dialog;
using FlyoutNavigation;
namespace GoodTVIOS { [Register ("AppDelegate")] public partial class AppDelegate : UIApplicationDelegate { UIWindow window;
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds) {
RootViewController = new MainController ()
};
window.MakeKeyAndVisible ();
return true;
}
}
}
$$MyStoryboardViewContoller.cs
using System;
using Foundation; using UIKit;
using MonoTouch.Foundation; using MonoTouch.UIKit;
using System.CodeDom.Compiler; using FlyoutNavigation; using Utilities;
namespace GoodTVIOS { partial class MyStoryboardViewController : UIViewController { public FlyoutNavigationController navigation { get; set; }
UtilitiesClass util;
public MyStoryboardViewController (IntPtr handle) : base (handle)
{
}
public MyStoryboardViewController()
{
NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, delegate
{
navigation.ToggleMenu();
});
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
util = new UtilitiesClass ();
//email = dev.intern@creationfilms.com
//pass =intern20152
txtUname.Text = "dev.intern@creationfilms.com";
txtPass.Text = "intern20152";
}
partial void btnLogin_TouchUpInside (UIButton sender)
{
Console.WriteLine("btnLogin_TouchUpInside");
string status="";
string response="";
util.UserLogin(txtUname.Text,txtPass.Text,out status,out response);
Console.WriteLine("status "+status);
//controller.UserName = txtPass.Text;
if (status=="OK")
{
HomePageViewController HomePVC = this.Storyboard.InstantiateViewController("HomePageViewController")
as HomePageViewController;
this.NavigationController.PushViewController(HomePVC, true);
// CHannelViewController channel =this.Storyboard.InstantiateViewController("CHannelViewController") // as CHannelViewController; // channel.UserName = txtUname.Text; // this.NavigationController.PushViewController(channel,true);
}
if (status=="DOWN")
{
new UIAlertView("Alert", "Email/Password is Incorrect", null, "OK", null).Show();
}
}
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Action, delegate
{
navigation.ToggleMenu();
});
}
}
}
Here's my code. Please let me know the solution.
Flyout navigation has been working fine.But after I converted my code into unified. I got a problem in my app which contain login screen. after we login, the flyout navigation table view click(row click) is not working(unable to move next view controller) but if I went to new presentviewcontroller(i.e card.io) and come back its working fine.
Please find the below code.
I'm calling homeController from LoginController using below code Home homeObject=new Home(); this.NavigationController.PushViewController(this.homeObject,true);
Home
FlyoutNavigationController myflyout = new FlyoutNavigationController (); UIView background = new UIView (); background.ContentMode = UIViewContentMode.ScaleAspectFill; background.Add (bg);
View.Bounds.Width, View.Bounds.Height)); bg.Image = imgBackground; bg.ContentMode = UIViewContentMode.ScaleAspectFill;
UIColor.Clear; myflyout.NavigationTableView.SectionIndexColor = UIColor.White;
UITableViewCellSeparatorStyle.None; myflyout.NavigationTableView.SectionHeaderHeight = 20; myflyout.NavigationTableView.Frame = new CGRect (0f, 250f, View.Bounds.Width, View.Bounds.Height); myflyout.NavigationTableView.TintColor = new UIColor (1, 1, 1, 1);
UIViewController,
UIViewController, new AddCategory (flyout)as UIViewController, new BuildSettings (flyout)as UIViewController,
userorgid, flyout)as UIViewController, new Bitcoinhistory (username, password, this, mailid, CustomerID, userorgid, flyout)as UIViewController, new SalesProductChart (flyout)as UIViewController, new Debit_Settings (userid, username, password, phoneno, mailid, dob, SellerToken, this, flyout)as UIViewController, new UploadMerchantLogo (flyout)as UIViewController, new Changepassword (username, this, flyout)as UIViewController, new Debit_table_help (this, flyout)as UIViewController, new Support (userid, mailid, phoneno, this, flyout),
please help me to solve this.
@Clancey @lubiluk @migueldeicaza @dvdsgl @timrisi