ios - Adding View to main Window on firs launch in the ipad application -


i have app. in doing when app first launch adding loginviewcontroller other wise add splitviewcontroller works fine problem want when loginviewcontroller added , when press singbutton on loginscreen should add splitviewcontroller window code when press login singin app closes , when open again shows me splitviewcontroller

here code

   [[nsuserdefaults standarduserdefaults] registerdefaults:[nsdictionary dictionarywithobjectsandkeys:[nsnumber numberwithbool:yes],@"firstlaunch",nil]];     if ([[nsuserdefaults standarduserdefaults] boolforkey:@"firstlaunch"]) {           [[nsnotificationcenter defaultcenter] addobserver:self                                              selector:@selector(actionnotificationdata:)                                                  name:@"reloadsplit"                                                object:nil];          [self.window addsubview:[loginviewcontroller view]];    )    else{         [self.window addsubview:[splitviewcontroller view]];       }           -(void)actionnotificationdata:(nsnotification *)notification {            [self.splitviewcontroller removefromparentviewcontroller];         window = [uiapplication sharedapplication].keywindow;       if (!window)        window = [[uiapplication sharedapplication].windows objectatindex:0];      [[[window subviews] objectatindex:0] addsubview:splitviewcontroller];            [window makekeyandvisible];         } 

here signinbuttonaction

                [[nsnotificationcenter defaultcenter] postnotificationname:@"reloadsplit" object:self];              [self dismissmodalviewcontrolleranimated:yes]; 

my code

  self.splitviewcontroller =[[uisplitviewcontroller alloc]init]; self.rootviewcontroller=[[rootviewcontroller alloc]init]; self.detailviewcontroller=[[[firstdetailviewcontroller alloc]init] autorelease]; self.loginviewcontroller=[[[loginviewcontroller alloc]init] autorelease];   uinavigationcontroller *rootnav=[[uinavigationcontroller alloc]initwithrootviewcontroller:rootviewcontroller]; uinavigationcontroller *detailnav=[[uinavigationcontroller alloc]initwithrootviewcontroller:detailviewcontroller];    if ([detailnav.navigationbar respondstoselector:@selector(setbackgroundimage:forbarmetrics:)] ) {     uiimage *image = [uiimage imagenamed:@"nav.png"];     [detailnav.navigationbar setbackgroundimage:image forbarmetrics:uibarmetricsdefault];        }     user_name=@"jamshaid";  isclickedlogin=@"no";       userlogin=@"logout";    self.splitviewcontroller.viewcontrollers=[nsarray arraywithobjects:rootnav,detailnav,nil]; self.splitviewcontroller.delegate=self.detailviewcontroller; 

first add loginviewcontroller self.window.rootviewcontroller such like

(here added uinavigationcontroller too)

- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions {     self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]];     [[uiapplication sharedapplication] setstatusbarstyle:uistatusbarstyleblackopaque];      loginviewcontroller *loginviewcontroller = [[loginviewcontroller alloc] init];     uinavigationcontroller *loginnvcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:loginviewcontroller];     loginnvcontroller.navigationbarhidden = yes;     self.window.rootviewcontroller = loginnvcontroller;      self.window.backgroundcolor = [uicolor whitecolor];     [self.window makekeyandvisible];      return yes; } 

and after in loginviewcontroller.m

this method of signinbutton, call when tapped signinbutton

-(void)passtosplitviewcontroller:(uibutton *)sender {     [self.navigationcontroller pushviewcontroller:self.splitviewcontroller animated:yes]; } 

or

put following code @ end of didfinishlaunchingwithoptions

//add below line if u need populate login screen before uisplitviewcontroller! loginviewcontroller *loginview = [[loginviewcontroller alloc] init];             [self.window addsubview:splitviewcontroller.view];  //add below line if u need populate login screen before uisplitviewcontroller!  [splitviewcontroller presentmodalviewcontroller:loginview animated:no]; 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -