ios - how to show the views added in view controller -
i had created the view programatically not display on screen , gives message in console that
failed instantiate default view controller uimainstoryboardfile 'main' - perhaps designated entry point not set?
here code
-(bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]] ; exmtableviewcontroller *vc =[[exmtableviewcontroller alloc] init]; self.window.rootviewcontroller=vc; self.window.backgroundcolor =[uicolor whitecolor]; [self.window makekeyandvisible]; return yes; }
*code in viewdidload *
- (void)viewdidload { [super viewdidload]; uiimageview *img =[[uiimageview alloc] initwithframe:cgrectmake(10, 10, 100, 20)]; self.imageview=img; [self.view addsubview:self.imageview]; uilabel *lbl =[[uilabel alloc] initwithframe:cgrectmake(10, 10, 100, 20)]; lbl.text =@"hello"; self.view =lbl; }
instead line self.view =lbl;
, use [self.view addsubview:lbl];
add subview view.
Comments
Post a Comment