开发者

IPhone adding UiComponents to UiScrollView on run time

开发者 https://www.devze.com 2023-03-18 03:37 出处:网络
I\'m new to objective C, I have a view based application which communicates with a web service and recives an xml, parse it and map its contens an appropriate view component (e.g if thats a date show

I'm new to objective C, I have a view based application which communicates with a web service and recives an xml, parse it and map its contens an appropriate view component (e.g if thats a date show the question with datepicker, if question has 2 values show it with a segmented control, if more with a pickerview..etc) so its a dynamic questionary with m开发者_C百科any pages filled with multiple components.

how can I do the design for the mapping the xml response into related UI view components on runtime? I want to make the code as object orient as possible and not too many if elses in my view controller class, but instead it should only receive a let's say "uiview object" filled with necessary view components and it will just show it. I have a UiScrollView and want to add new different approprite Uicomponents(Picker, textbox, label..) to it on real time, How can I do this? I think in the Interface builder I only need to put the scrollview and the rest will be in code? and using a scrollview a good choice here? thanks.


[self.view addSubView: imageview];
[self.scrollView addsubview:pickerview];
[self.view addSubView:scrollview];

like wise the custom view may be like uibutton,textfield,textview,imageview


you can't do without a UIScrollView. you have to define the set of elements you wan to inject into your view and make case statement for the xml data you are receiving in your receiving data handler.

If you are new to Objective-C (i.e. CocoaTouch) and if your polls are fixed enough , maybe you could try setting up the differents views in the code and the data you are retrieving from the net will be to decide which view to display.

another tip will be to subclass UIKit elements to init them from a XML node.

0

精彩评论

暂无评论...
验证码 换一张
取 消