0

I have an application with objects that have relationships. A "Person" object can have multiple "evaluation" objects. It starts with a navigation controller. Tapping a Person object from a table view takes you to a tableview with all their "evaluations". At the top of all their evaluations, I have 1 static cell that says "All Evaluations" in which I would like to display all their evaluations.

The problem is since I won't know in advance how many evaluations they have, I can't create the right amount of textfields to display all the evaluations.

Let's say this particular person has 7 Evaluations and all evaluation objects have just 1 attribute, "time". How could I dynamically create 7 text fields with the correlating 7 Evaluation objects displayed in them?

Sorry if I was unclear. I have tried creating a UIView in IB and then creating that same view multiple times for each evaluation but failed miserably. Can anyone push me in the right direction please?

1
  • could you just make a tableview for the evaluations ? Commented Sep 21, 2013 at 22:49

1 Answer 1

2

If you are using IB you are reusing the same view over and over. Create new UILabel with it:

float currentY = 0.0f;
float spacing =5.0f;

for(Evaluation *evaluation in EvalationsArray)
{
    UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(yourX,currentY,yourWidht, yourHeight)];
    [textLabel setText:[NSString stringWithFormat:@"%@ : %@",evaluation.name,evaluation.time]];
    [self.view addSubview:textLabel]
    currentY = currentY+spacing+yourHeight;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.