iphone - scrollview not working from database images -
i stored images in local database. fetched images database using sqlite , displayed using array. added image array in scrollview. scrollview not working.
code:
.h file:
nsmutablearray *arraysofs; -(void)unloadpreviouspage:(int)index; -(void)loadnextpage:(int)index; .m file:
-(void)click:(id)sender{ scroll = [[uiscrollview alloc] initwithframe:cgrectmake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; scroll.pagingenabled = yes; (int = 0; i<[self.arraysofs count]; i++ ) { nslog(@"index %d",i); mmageview=[[uiimageview alloc]initwithframe:cgrectmake(20+(i*74), 420, 72, 72)]; [mmageview setimage:((mysof *) [self.arraysofs objectatindex:i]).photo]; [scroll addsubview:mmageview]; } [scroll setcontentsize:cgsizemake(cgrectgetmaxx(mmageview.frame),self.view.frame.size.height)]; [self.view addsubview:scroll]; }
in click methos set content size of scrollview follows,
-(void)click:(id)sender{ (int index = 0; index < [self.arraysofs count]; index ++ ) { nslog(@"index %d",index); mmageview=[[uiimageview alloc]initwithframe:cgrectmake(20+(index*74), 52, 72, 72)]; [self.view addsubview:mmageview]; soflistsql * mysofs =[[soflistsql alloc] init]; self.arraysofs = [mysofs getmylists]; [mmageview setimage:((mysof *) [self.arraysofs objectatindex:index]).photo]; } [your_scrollview setcontentsize:cgsizemake(cgrectgetmaxx(mmageview.frame),self.view.frame.size.height)]; }
Comments
Post a Comment