i am very new to iOS development, i am stuck with issue here and cant find solution anywhere else.
I need to dynamically generate fields on profileDetailViewController.m which is type of UIViewController,
Fields I want on view are stored in Array which looks like this,
Array:(
{
fieldName = Full Name;
value = Neil G.;
},
{
fieldName = Aboutn me;
value = "a web dev..";
},
{
fieldName = State;
value = Colorado;
},
{
fieldName = City;
value = Denver;
},
{
fieldName = Website;
value = "http://google.com";
},
{
fieldName = College University;
value = "DSU";
},
{
fieldName = Graduation Year;
value = 2011;
}
)
I am just trying to make it like contacts in IPhone,
Initially load page as display mode with edit button, so when Edit mode it should turn into form with editable fields. Any good tutorial would be great. I will appreciate your help. Thank you.
first grab the size of your array of fields:
int fieldCount = [Array count];then create a wrapperView we will place a scroll view on, since for all we know you will have more fields than you can fit on the screen!
Now I’m going to just add some labels for the purposes here, but you could easily make them buttons or what have you. I will have them be 21 height with a 10 pixel space in between.
So now we need to set the
contentSizeof the scrollView,Now we can tell the scrollView how large it content size needs to be, and then add all the labels. I am going to assume your array is filled with objects called Details which have a fieldName and a Value, because you didn’t really specify.
not sure if you want them to be labels like this, but that is easily changed. There may be a few more things, like implementing UIScrollViewDelegate and then
scrollView.delegate = selfsomewhere, but I’m not sure. Hope this helps!