iphone - Programmatically displaying Storyboard view -
i using storyboard facing error shown in below code executed no page show or action in simulator show black screen after launching 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 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 , conditions page"); } return yes; }
error
this error face when not choose entry point in storybroad initial view controller.
2013-07-17 19:38:12.749 beinformed[1011:c07] failed instantiate default view controller uimainstoryboardfile 'mainstoryboard' - perhaps designated entry point 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 , conditions page
error
this error face when choose entry point in storybroad 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 instance 0x71b2f50 2013-07-17 19:53:26.176 beinformed[1057:c07] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[clstermsandconditionviewcontroller pushviewcontroller:animated:]: unrecognized selector sent instance 0x71b2f50'
by way, know you've solved issue, wanted suggest flow. could, alternatively, start standard initial scene (which can without code in app delegate), have viewwillappear
determine if need terms , conditions (t&c), , if so, present separate scene modally (either animated or not animated, see fit). can have user's confirmation of t&c dismiss terms , conditions scene , you'll @ standard "initial" scene.
if way, t&c dismissed, don't have play around changing rootviewcontroller
programmatically, top level scene of navigation controller stays standard "initial" scene things poptorootviewcontroller
work without slight of hand, don't have hide navigation bar on t&c page, etc. lends flow might present user option of seeing t&c again (e.g. buried on "settings" or "about" scenes, if have appropriate place show it).
and if you're wondering how programmatically go t&c, define segue initial scene t&c scene:
then select segue , give identifier:
and initial scene's viewwillappear
performseguewithidentifier
, such as:
- (void)viewwillappear:(bool)animated { [super viewwillappear:animated]; bool hasacceptedtermsandconditions = ...; if (!hasacceptedtermsandconditions) { [self performseguewithidentifier:@"termsandconditions" sender:self]; } }
i'm glad solved issue, wanted suggest alternative flow.
Comments
Post a Comment