ios - UIScrollview not scrolling interface builder -
i adding uiscrollview
interface builder xib
file. scrollview
child of viewcontroller's
view , has other siblings on viewcontroller's
view.
now setting contentsize
of scrollview
in viewdidload
method , tried set in viewdidlayoutsubviews
method scrollview
doesn't scroll. sure content area of scrollview
bigger frame of scollview
.
every thing works fine when add scrollview
in code using following line
self.scrollview = [[uiscrollview alloc] initwithframe:cgrectmake(20.0, 58.0, 282.0, 200.0)]
but didn't scroll @ when use iboutlet
in code here code viewdidload
scollview
interface builder.
- (void)viewdidload { [super viewdidload]; alog(); nsuinteger = 0; float margin = 0.0; uiimage *previewimg = nil; (i = 0; < [[_settingsdict objectforkey:@"fullscreenwidgetidsarray"] count]; i++) { previewimg = [uiimage imagenamed:[nsstring stringwithformat:@"image_%@", _dict[@"images"][i]]]; if (previewimg == nil) { [uiimage imagenamed:@"image_2.png"]; } uiimage *backgroundimg = [uiimage imagenamed:@"image_border.png"]; uiimage *backgroundhighlightedimg = [uiimage imagenamed:@"image_selected.png"]; bool selected = [_dict[@"images"][i] unsignedintegervalue] == [_dict[@"id"] unsignedintegervalue]; uiimageview *gridelementview = [[uiimageview alloc] initwithimage:backgroundimg]; [gridelementview sethighlightedimage:backgroundhighlightedimg]; [gridelementview sethighlighted:selected]; gridelementview.userinteractionenabled = yes; uibutton *button = [uibutton buttonwithtype:uibuttontypecustom]; button.frame = cgrectmake(6, 5, previewimg.size.width, previewimg.size.height); [button setimage:previewimg forstate:uicontrolstatenormal]; button.contentmode = uiviewcontentmodecenter; margin = (_scrollview.frame.size.width - kelements_per_row * (gridelementview.frame.size.width + 2*kpreview_border_size))/3; gridelementview.frame = cgrectmake(margin + i%2*(margin + gridelementview.frame.size.width + 2*kpreview_border_size), margin + i/2*(margin + gridelementview.frame.size.height + 2*kpreview_border_size), gridelementview.frame.size.width + 2*kpreview_border_size, gridelementview.frame.size.height + 2*kpreview_border_size); button.tag = gridelementview.tag = [_settingsdict[@"fullscreenwidgetidsarray"][i] unsignedintegervalue]; [button addtarget:self action:@selector(previewbtnpressed:) forcontrolevents:uicontroleventtouchupinside]; [_thumbnailsviewsarray addobject:gridelementview]; [gridelementview addsubview:button]; [_scrollview addsubview:gridelementview]; } _scrollview.contentsize = cgsizemake(_scrollview.frame.size.width, margin + (i/2)*(margin + previewimg.size.height + 2*kpreview_border_size)); nslog(@"contentsize : %@",nsstringfromcgsize(_scrollview.contentsize)); }
in code adding uibuttons
inside scrollview
in 2 columns. there total 6 uibuttons
needs added in scrollview
. these button added scrollview
not scroll @ all. making scrollenabled
property yes didn't work.
any great.
thanks
Comments
Post a Comment