Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6340675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T19:52:51+00:00 2026-05-24T19:52:51+00:00

I am trying to add elements to a scroll view using this code: int

  • 0

I am trying to add elements to a scroll view using this code:

int missionCount;
[connection release];

NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];

NSDictionary *missionsDict = [responseString JSONValue];
/*NSArray *luckyNumbers = [json objectWithString:responseString error:&error];*/
NSLog(@"user Info array is: %@", missionsDict);
//    NSDictionary *array = [luckyNumbers1 objectForKey:@"data"];
NSDictionary *missionsData;
missionsData = [missionsDict objectForKey:@"data"];
NSLog(@"missionsData is: %@", missionsData);
NSEnumerator *inner = [missionsData objectEnumerator];
missionsScroll.contentSize = CGSizeMake(768, 1005);

id value;
int badgeY1;
int badgeY2;
int badgeY3;
badgeY1 = 146;
badgeY2 = 188;
badgeY3 = 188;
while((value = [inner nextObject])) {
    NSLog(@"value is: %@", value);
    NSLog(@"progress is: %@", [value objectForKey:@"progress"]);
    NSLog(@"user Info array is: %@", missionsDict);
    NSLog(@"name is: %@",[value objectForKey:@"reward_definitions"]);
    NSLog(@"missionsData is: %@", missionsData);
    NSDictionary *moreData;
    moreData = [value objectForKey:@"reward_definitions"];
    NSEnumerator *inner2 = [moreData objectEnumerator];
    id value2;
    int badgeX;
    int badgeCount;
    badgeX = 0;
    badgeCount = 0;
    while((value2 = [inner2 nextObject])) {
        UIProgressView *progressView;
        progressView = [[UIProgressView alloc] initWithFrame:CGRectMake(323, badgeY1, 372, 9)];
        float progressValue;
        progressValue = ([[[value objectForKey:@"progress"] objectForKey:@"earned"] floatValue] / [[[value objectForKey:@"progress"] objectForKey:@"possible"] floatValue]);
        NSLog(@"progressValue is: %f", progressValue);
        [progressView setProgress:progressValue];
        [missionsScroll addSubview:progressView];
        UILabel *missionName;
        missionName = [[UILabel alloc] initWithFrame:CGRectMake(66, badgeY1, 227, 21)];
        missionName.backgroundColor = [UIColor clearColor];
        missionName.textColor = [UIColor whiteColor];
        missionName.font = [UIFont fontWithName:@"Heiti TC" size:23.0];
        missionName.text = [value objectForKey:@"name"];
        [missionsScroll addSubview:missionName];

        UILabel *requirementsLabel;
        requirementsLabel = [[UILabel alloc] initWithFrame:CGRectMake(66, badgeY2+25, 227, 21)];
        requirementsLabel.backgroundColor = [UIColor clearColor];
        requirementsLabel.textColor = [UIColor whiteColor];
        requirementsLabel.font = [UIFont fontWithName:@"Papyrus" size:19];
        requirementsLabel.text = @"To complete you need:";
        [missionsScroll addSubview:requirementsLabel];

        NSLog(@"Image URL is: %@", [value2 objectForKey:@"image_url"]);
        NSURL *url1 = [NSURL URLWithString: [NSString stringWithFormat:@"%@", [value2 objectForKey:@"image_url"]]];            
        NSData *urlData1 = [NSData dataWithContentsOfURL:url1];
        UIImage *image1 = [UIImage imageWithData:urlData1];
        UIImageView *badge = [[UIImageView alloc] initWithImage:image1];
        [badge setFrame:CGRectMake(badgeX, badgeY2+70, 70, 70)];               
        [missionsScroll addSubview:badge];
        [badge release];
        badgeCount = badgeCount+1;
        NSLog(@"badgeCount is: %i", badgeCount);
        if (badgeCount == 4) {
            NSLog(@"Badge Count = 4");
            badgeY2 = badgeY2 +70;
            badgeX = 0;
            badgeCount = 0;
        } else {
            NSLog(@"Badge Count ≠ 4");
            badgeX = badgeX +75;
        }

    }
    NSLog(@"1st While loop done");

    // NSLog(@"reward_definitions is: %@", [missionsData objectForKey:@"id"]);
    //       NSLog(@"Image URL is: %@", [[value objectForKey:@"reward_definitions"] objectForKey:@"image_url"]);
    //if ( [array isKindOfClass:[NSDictionary class]] ) {
    badgeY1 = badgeY1 +200;

    badgeY2 = badgeY2 +200;

    badgeY3 = badgeY3 +200;
    missionCount = missionCount+1; 
}
NSLog(@"While loops done");

for (int a; missionCount > 4; a = a+1) {
    missionsScroll.contentSize = CGSizeMake(776, missionsScroll.contentSize.height+200);
}

Nothing is showing up in the scroll view.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T19:52:53+00:00Added an answer on May 24, 2026 at 7:52 pm

    It’s not obvious what is happening, but first things to check are where the views are valid (not nil) and that this code is running on the main thread.

    Put these in and post the results.

       NSLog(@"missionsScroll: %@", (missionsScroll==nil)?@"NIL":@"OK");
       NSLog(@"progressView: %@", (progressView==nil)?@"NIL":@"OK");
       NSLog(@"missionName: %@", (missionName==nil)?@"NIL":@"OK");
       NSLog(@"mainThread: %@", ([NSThread isMainThread])?@"OK":@"Background Thread");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying add a tab to my web page that looks like this: Using
I am trying to add all the elements in array using push . then
I'm trying to put together some jQuery code that will add form elements (input
Trying to make a make generic select control that I can dynamically add elements
I'm trying to add a class to some input elements depending on the type,
This may be a simple answer, but I'm trying to add a dom-created element
I'm using wxPython 2.8 and i'm trying to add scrollbar capabilities on the right
I am trying to have a method in my code behind at runtime add
I'm trying to add style elements to all ALL the head elements in a
I have been trying to add onclick event to new elements I added with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.