iOS Question inline OBJC

Discussion in 'iOS Questions' started by narek adonts, Feb 25, 2015.

  1. narek adonts

    narek adonts Well-Known Member Licensed User

    I am trying to hide the TabBar with this code but it doesnt hide it.
    could someone advise please.

    Code:
    #If OBJC


    - (void) hideTabBar:(UITabBarController *) tabbarcontroller
    {
        CGRect screenRect = [[UIScreen mainScreen] bounds];

        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:0.5];
        float fHeight = screenRect.size.height;
        if(  UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation) )
        {
            fHeight = screenRect.size.width;
        }

        for(UIView *view in tabbarcontroller.view.subviews)
        {
            if([view isKindOfClass:[UITabBar class]])
            {
                [view setFrame:CGRectMake(view.frame.origin.x, fHeight, view.frame.size.width, view.frame.size.height)];
            }
            else
            {
                [view setFrame:CGRectMake(view.frame.origin.x, view.frame.origin.y, view.frame.size.width, fHeight)];
                view.backgroundColor = [UIColor blackColor];
            }
        }
        [UIView commitAnimations];
    }
    #End if

    Private Sub HideT(tskbr As TabBarController)
    Dim nm As NativeObject=app

    nm.RunMethod(
    "hideTabBar:",Array(tskbr))
    End Sub

    when I am trying this method the app crush.

    Narek
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Which error do you get?

    In most cases it is not a good idea to access the internal views of the standard controllers. This is considered private api.
     
  3. narek adonts

    narek adonts Well-Known Member Licensed User

    it says method not found.
    what should I declare as Native Object?

    Code:
    #If OBJC


    -(void)MakeTabBarHidden:(UITabBarController*)tabBarController :(BOOL)hide
    {
        // Custom code to hide TabBar
        if ( [tabBarController.view.subviews count] < 2 ) {
            return;
        }

        UIView *contentView;

        if ( [[tabBarController.view.subviews objectAtIndex:0] isKindOfClass:[UITabBar class]] ) {
            contentView = [tabBarController.view.subviews objectAtIndex:1];
        } else {
            contentView = [tabBarController.view.subviews objectAtIndex:0];
        }

        if (hide) {
            contentView.frame = tabBarController.view.bounds;      
        }
        else {
            contentView.frame = CGRectMake(tabBarController.view.bounds.origin.x,
                 tabBarController.view.bounds.origin.y,
                 tabBarController.view.bounds.size.width,
                 tabBarController.view.bounds.size.height - tabBarController.tabBar.frame.size.height);
        }

        tabBarController.tabBar.hidden = hide;
    }
    #End if


    Private Sub Hide(tb as TabBarController)
    dim no as NativeObject=Me
    no.RunMethod(
    "MakeTabBarHidden:",Array(tb,True))

    End Sub
    Narek
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    The method name ends with two colons (one for each parameter).
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice