Friday, 15 January 2010

ios - how to have UIImage below UILabel or UITextView in a scrollview -



ios - how to have UIImage below UILabel or UITextView in a scrollview -

how can set uilabel or uitextviewbelow uiimageview in uiscrollview when image scrolled, label or text should scrolled along simultaneously. need guidance on this.

you must implement uiscrollview , add together desired subview (uiimageview , uilabel in case).

in viewdidload:

uiscrollview *scrollview = [[uiscrollview alloc] initwithframe:cgrectmake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; scrollview.backgroundcolor = [uicolor redcolor]; uiimageview *imageview = [[uiimageview alloc] initwithframe:cgrectmake(0, 0, scrollview.frame.size.width * 2, 100)]; imageview.backgroundcolor = [uicolor bluecolor]; uilabel *label = [[uilabel alloc] initwithframe:cgrectmake(imageview.frame.size.width, 0, imageview.frame.size.width * 2, 40)]; label.text = @"hello world"; [self.view addsubview:scrollview]; [scrollview addsubview:imageview]; [scrollview addsubview:label];

do not forget set uiscrollview's content size > frame:

scrollview setcontentsize:cgsizemake(self.view.frame.size.width * 2, self.view.frame.size.height);

this should provide guidance requested.

ios uiscrollview uiimageview uilabel

No comments:

Post a Comment