Reputation: 20920
I have created Slide Menu in Xamarin.iOS with below library https://github.com/thedillonb/MonoTouch.SlideoutNavigation
SplashViewController.cs
window = new UIWindow(UIScreen.MainScreen.Bounds);
Menu = new SlideoutNavigationController();
var storyboard = UIStoryboard.FromName("Main", null);
var webController = storyboard.InstantiateViewController("HomeViewController") as HomeViewController;
Menu.MainViewController = new MainNavigationController(webController, Menu);
Menu.MenuViewController = new MenuNavigationController(new DummyControllerLeft(), Menu) { NavigationBarHidden = true };
window.RootViewController = Menu;
window.MakeKeyAndVisible();
DummyControllerLeft.cs
public override void ViewDidLoad()
{
base.ViewDidLoad();
TableView.Frame = new RectangleF((float)TableView.Frame.Left, 30, (float)TableView.Frame.Width, (float)(View.Frame.Size.Height - 30));
headerView = new UIView();
headerView.Frame = new CoreGraphics.CGRect(0, 0, TableView.Frame.Width, 140);
profileImage = new UIImageView();
profileImage.Frame = new CoreGraphics.CGRect(10, 10, 70, 70);
profileImage.Layer.CornerRadius = 35;
profileImage.ClipsToBounds = true;
profileImage.Image = UIImage.FromBundle("gargi_logo.png");
userName = new UILabel();
userName.Frame = new CoreGraphics.CGRect(10, 90, TableView.Frame.Width - 20, 20);
userName.Font = GargiFontAndSize.B14();
userName.TextColor = UIColor.White;
headerView.AddSubview(userName);
userRole = new UILabel();
userRole.Frame = new CoreGraphics.CGRect(10, 110, TableView.Frame.Width - 20, 20);
userRole.Font = GargiFontAndSize.B14();
userRole.TextColor = UIColor.White;
headerView.AddSubview(userRole);
headerView.AddSubview(profileImage);
TableView.TableHeaderView = headerView;
TableView.ContentInset = new UIEdgeInsets(20, 0, 0, 0);
GetUserItemData();
SetSidePanel();
}
Its working fine.
Screen 1:
but when i scroll it is Interfering with Status Bar see below image.
Screen 2:
I have tried almost all solution or workaround but nothing is help to me. few of them are below.
Tried 1 :
TableView.ContentInset = new UIEdgeInsets(20, 0, 0, 0);
Tried 2 :
TableView.ScrollRectToVisible(new CGRect(0, 0, 1, 1), true);
Tried 3 :
EdgesForExtendedLayout = UIRectEdge.None;
ExtendedLayoutIncludesOpaqueBars = false;
AutomaticallyAdjustsScrollViewInsets = false;
I tried to solve this problem for last 6 hour but nothing is Help for me.
Any Help will be Appreciated.
Upvotes: 0
Views: 283
Reputation: 3276
If all of your menus 'rows' are in a single section, you could change your 'TableHeaderView' to a 'SectionHeader' that would remain in place whilst the section scrolls and should in theory solve your problem.
I think you will likely need to create a source delegate class for your tableview to do this though because the property isn't exposed for the tableview by itself, so you'd need to do something like this:
Assign it to your table view:
yoursource source = new yoursource();
TableView.Source = source;
Create the delegate class:
using CoreGraphics;
using Foundation;
using System;
using UIKit;
namespace somenamespace
{
class yoursource : UITableViewSource
{
public ThreadTableSource(UITableView table, List<ConversationThread> Threads)
{
}
public override UIView GetViewForHeader(UITableView tableView, nint section)
{
headerView = new UIView();
headerView.Frame = new CoreGraphics.CGRect(0, 0, tableView.Frame.Width, 140);
profileImage = new UIImageView();
profileImage.Frame = new CoreGraphics.CGRect(10, 10, 70, 70);
profileImage.Layer.CornerRadius = 35;
profileImage.ClipsToBounds = true;
profileImage.Image = UIImage.FromBundle("gargi_logo.png");
userName = new UILabel();
userName.Frame = new CoreGraphics.CGRect(10, 90, tableView.Frame.Width - 20, 20);
userName.Font = GargiFontAndSize.B14();
userName.TextColor = UIColor.White;
headerView.AddSubview(userName);
userRole = new UILabel();
userRole.Frame = new CoreGraphics.CGRect(10, 110, tableView.Frame.Width - 20, 20);
userRole.Font = GargiFontAndSize.B14();
userRole.TextColor = UIColor.White;
headerView.AddSubview(userRole);
headerView.AddSubview(profileImage);
return headerView;
}
}
}
Link to section header xamarin guide.
Upvotes: 0