Programmatically display the angle

I am using a Storyboard that encounters an error as shown below. My code has been successfully executed, but their display or action on the simulator does not show only a black screen after starting the image.

ClsMainPageAppDelegate.h

#import <UIKit/UIKit.h> @interface ClsMainPageAppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end 

ClsMainPageAppDelegate.m

 #import "ClsMainPageAppDelegate.h" #import "ClsMainPageViewController.h" #import "ClsTermsandConditionViewController.h" @implementation ClsMainPageAppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. NSUserDefaults *fetchDefaults = [NSUserDefaults standardUserDefaults]; int message = [fetchDefaults integerForKey:@"checkvalue"]; NSLog(@"Message Hello : %i",message); if(message == 1) { UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; ClsMainPageViewController *mvc = [storyboard instantiateViewControllerWithIdentifier:@"BeIinformedPage"]; [(UINavigationController*)self.window.rootViewController pushViewController:mvc animated:NO]; NSLog(@"Launched Home Page"); } else { UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; ClsTermsandConditionViewController *mvc = [storyboard instantiateViewControllerWithIdentifier:@"termsandConditionControl"]; [(UINavigationController*)self.window.rootViewController pushViewController:mvc animated:NO]; NSLog(@"Launched Terms and Conditions Page"); } return YES; } 

Error

This error that I encounter when I do not select an entry point in storybroad is the initial view controller.

 2013-07-17 19:38:12.749 BeInformed[1011:c07] Failed to instantiate the default view controller for UIMainStoryboardFile 'MainStoryboard' - perhaps the designated entry point is not set? 2013-07-17 19:38:16.127 BeInformed[1011:c07] Message Hello : 0 2013-07-17 19:38:18.333 BeInformed[1011:c07] Launched Terms and Conditions Page 

Error

This error that I encounter when I select an entry point in storybroad is the Initial View Controller (termsandConditionControl)

  2013-07-17 19:53:19.839 BeInformed[1057:c07] Message Hello : 0 2013-07-17 19:53:26.175 BeInformed[1057:c07] - [ClsTermsandConditionViewController pushViewController:animated:]: unrecognized selector sent to instance 0x71b2f50 2013-07-17 19:53:26.176 BeInformed[1057:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ClsTermsandConditionViewController pushViewController:animated:]: unrecognized selector sent to instance 0x71b2f50' 
+6
source share
3 answers

By the way, I know that you solved the problem, but I just wanted to offer a different thread. You can, alternatively, always start with your standard start scene (which you can bypass without code in the application delegate), but have viewWillAppear determine if you need terms and conditions (T & C), and if so, Imagine a separate scene modally (animated or not animated as you see fit). You may have a T & C user confirmation, and then release the conditions scene and you will be returned to the standard “start” scene.

If you do this, your T&C will be rejected, you won’t have to play with programmatically changing the rootViewController , the top-level scene of the navigation controller always remains as the standard “initial” because things like popToRootViewController work without any manipulation, you no need to hide the navigation bar on the T&C page, etc. It also lends itself to a stream where you can present the user with the opportunity to see T&C again (for example, they are buried in the “settings” or “near” scenarios if you have a suitable place to display it).

And if you are wondering how to programmatically switch to T & C, you can define a segue from your initial scene to the T & C scene:

create segue

Then select this segment and give it an identifier:

segue identifier

And now your initial viewWillAppear scene could performSegueWithIdentifier , for example:

 - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; BOOL hasAcceptedTermsAndConditions = ...; if (!hasAcceptedTermsAndConditions) { [self performSegueWithIdentifier:@"TermsAndConditions" sender:self]; } } 

I'm glad you solved your problem, but I just wanted to offer an alternative thread.

+5
source

Finally solved my problem, I used this code

  UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; ClsTermsandConditionViewController *ivc = [storyboard instantiateViewControllerWithIdentifier:@"termsandConditionControl"]; UINavigationController *navigationController=[[UINavigationController alloc] initWithRootViewController:ivc]; self.window.rootViewController=nil; self.window.rootViewController = navigationController; [navigationController setNavigationBarHidden:YES]; [self.window makeKeyAndVisible]; 
+4
source

Ok The possible reason is that you might have missed the class / controller name assignment in the identity inspector to your controller in storyBoard. Then also check in your plist file that you have a storyboard entry with the appropriate name for your storyboard.

Hope this works. :)

0
source

Source: https://habr.com/ru/post/949654/


All Articles