iOS Question Subclass Page (UIViewController)

Discussion in 'iOS Questions' started by Semen Matusovskiy, Oct 12, 2019 at 10:59 PM.

  1. Semen Matusovskiy

    Semen Matusovskiy Well-Known Member Licensed User

    Hi, guys --

    To subclass UIViewController in XCode is enough simple due to wizards. For example,

    #import <UIKit/UIKit.h>

    @interface FirstViewController : UIViewController
    @implementation FirstViewController
    - (BOOL) prefersStatusBarHidden { NSLog(@
    "prefersStatusBarHidden"); return YES; }
    But how to do the same in B4I ?
    I tried to use Erel's shouldAutorotate as layout. shouldAutorotate works, but methods, which I try to add, are not called.

    Any ideas ?
  2. Erel

    Erel Administrator Staff Member Licensed User

    What are you trying to do?
  3. Semen Matusovskiy

    Semen Matusovskiy Well-Known Member Licensed User

    In B4I I created a new project and added
    #if OBJC
    @interface UIViewController (Test)
    @implementation UIViewController (Test)
    - (BOOL) shouldAutorotate { NSLog (@"shouldAutorotate"); return true; }
    - (BOOL) prefersStatusBarHidden { NSLog(@"StatusBar"); return YES; }
    - (UIStatusBarStyle) preferredStatusBarStyle { NSLog(@"StatusBarStyle"); return UIStatusBarStyleLightContent; }
    #End If
    shouldAutorotate is called, other methods - not.

    In Catalyna, XCode 11.1 I created a new project using "Tabbed App". In FirstViewController.m inside @implementation FirstViewController I added
    - (UIStatusBarStyle) preferredStatusBarStyle { NSLog(@"FirstView: preferredStatusBarStyle"); return UIStatusBarStyleLightContent; }
    - (BOOL) prefersStatusBarHidden { NSLog(@"FirstView: prefersStatusBarHidden"); return YES; }
    Then an analog code for SecondViewController.
    - (BOOL) prefersStatusBarHidden { NSLog(@"SecondView: prefersStatusBarHidden"); return NO; }
    - (UIStatusBarStyle) preferredStatusBarStyle { NSLog(@"SecondView: preferredStatusBarStyle"); return UIStatusBarStyleDarkContent; }
    Works fine.

    After this I added to main.m the same code as in B4I. IOS works as expected (methods are called inside main.m and First/SecondViewController).
    Last edited: Oct 14, 2019 at 10:46 PM
  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