0

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:

enter image description here

but when i scroll it is Interfering with Status Bar see below image.

Screen 2:

enter image description here

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.

Harshad Pansuriya
  • 20,189
  • 8
  • 67
  • 95
  • You're giving the view the height and width of your entire screen bound to render in (window = new UIWindow(UIScreen.MainScreen.Bounds);) You need to allow room for the top status bar. – JoeTomks Aug 29 '17 at 13:22
  • @Digitalsa1nt wait i add Top status bar height and check it.. – Harshad Pansuriya Aug 29 '17 at 13:24
  • @Digitalsa1nt but it also down the Whole Layout like NavigationBar and other thing. I want to keep other View Controller same as previous but only change in `DummyControllerLeft` which extend the `DialogViewController`. – Harshad Pansuriya Aug 29 '17 at 13:29
  • @Digitalsa1nt can you more elaborate it. i think it can solve my problem. – Harshad Pansuriya Aug 29 '17 at 13:36
  • The whole of the left dummy view is essentially a tableview, with that circular image etc in the header, so what that means is, when you scroll, it'll allow the whole left dummy view to scroll upto the topmost point of the table, which is at the top of the screen. The reason you don't see this when it first loads, is because it applies ContentInsets which pushes the header below the status bar. – JoeTomks Aug 29 '17 at 13:45
  • So that being said, you would need the tableview (left dummy view) to be inside a view of it's own, that forces the uppermost part of the tableview to sit below the status bar. This can be done for the tab bar at the bottom as well. – JoeTomks Aug 29 '17 at 13:46
  • @Digitalsa1nt yes that is the Point. To solve it I put contentInsets to ` `ViewDidLayoutsubview` then also it not work. – Harshad Pansuriya Aug 29 '17 at 13:46
  • @Digitalsa1nt how can i add tableview to any view because my Tableview come from `DialogViewController`. Can give the key point how to manage it. – Harshad Pansuriya Aug 29 '17 at 13:48
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/153186/discussion-between-ironman-and-digitalsa1nt). – Harshad Pansuriya Aug 30 '17 at 03:48

1 Answers1

0

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.

JoeTomks
  • 3,243
  • 1
  • 18
  • 42