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 9171433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:09:44+00:00 2026-06-17T16:09:44+00:00

I’m working on a large project that consists of several sections, each with a

  • 0

I’m working on a large project that consists of several sections, each with a varying number of slides.

I’m trying to dynamically create a navigation bar where the number of buttons correspond with the loaded section’s slides. The issue I have is setting the on/off appearance of the button as each slide loads.

I create the navigation bar when the section is created and the appearance of each button should be updated as each slide is loaded. I am trying to target each button using viewWithTag. The appearance is fine when the first slide of the section loads, but when I hit the next button everything disappears. Curiously, when clicking back to the first slide, everything appears as it should.

When a section is loaded, a mutable array of dictionary objects is created containing the necessary slide information. I have a class method (- (void) newbutton:(NSString *) title withIndex:(int) index atPosition:(int) Xpos) that is called from the Main View that creates a custom “ON” and “OFF” button through a for-loop, passing title and index arguments from a plist file. After that, the slide at index 0 is loaded.

Main View

- (void) findStory:(NSString *) presentation
{

    [model loadStory:presentation];

    int storyCount = model.currentStory.count;
    if (storyCount > 1) {
        int distribution = 700 / (storyCount - 1); // 700 = width of Navigation Rule
        int Xpos = 89; // 89 = X position of Navigation Rule

        // Build Navidation trail
        for (int i = 0; i < model.currentStory.count; i++) {

            NSLog(@"findStory(): Item Title: %@", [model.currentStory[i] objectForKey:@"name"]);

            [nav newbutton:[model.currentStory[i] objectForKey:@"name"] withIndex:i atPosition:Xpos];
            navButton = nav.button;
            navDot = nav.buttonDot;
            [self.navHolder addSubview:navDot];
            [self.navHolder addSubview:navButton];
            Xpos += distribution;
        }
    }

    [self newPage:model.pageIndex];
}

- (void)newPage:(int) index
{
    NSLog(@"newPage(): Requested page Index is %i", model.pageIndex);
    // Code that finds and loads the slide  

    // At the end the navigation appearance is set
    [self setNavAppearance:index];
}

- (void) setNavAppearance:(int) index
{
    NSLog(@"setNavAppearance(): Setting navigation appearance...");
    int storyCount = model.currentStory.count;

    if (storyCount > 1) {
        for (int i = 0; i < storyCount; i++) {
            int pressedIndex = i + 20;
            int viewTag = i;
            UIButton *onButton = (UIButton *)[self.navHolder viewWithTag:viewTag];
            if (i != index) {
                onButton.hidden = YES;
            } else {
                onButton.hidden = NO;
            }

            UIButton *offButton = (UIButton *)[self.navHolder viewWithTag:pressedIndex];
            offButton.hidden = NO;

        }
    }

    NSLog(@"setNavAppearance(): navigation appearance set.");
}

nav Class Method

- (void) newbutton:(NSString *) title withIndex:(int) index atPosition:(int) Xpos
{
    buttonIndex = index;

    button = [[UIButton alloc] init];

    int labelXPosition = (Xpos - 75);
    int dotXposition = (Xpos - 10);

    // ON Button
    buttonLabel = [[UILabel alloc] initWithFrame:CGRectMake(labelXPosition, 637, 150, 55)];
    buttonLabel.textColor = [UIColor blackColor];
    buttonLabel.font = [UIFont fontWithName:@"HelveticaNeue-CondensedBold" size:12];
    buttonLabel.textAlignment = NSTextAlignmentCenter;
    buttonLabel.lineBreakMode = NSLineBreakByWordWrapping;
    buttonLabel.numberOfLines = 2;
    buttonLabel.text = title;
    buttonLabel.backgroundColor = [UIColor clearColor];
    buttonLabel.textColor = [UIColor colorWithRed:0.047f green:0.337f blue:0.494f alpha:1.0f];
    [self.button addSubview:buttonLabel];

    dot = [[UIImageView alloc] initWithFrame:CGRectMake(dotXposition, 702, 20, 20)];
    [dot setImage:[UIImage imageNamed:@"buttonPressed.png"]];
    [self.button addSubview:dot];

    button.tag = buttonIndex;

    // OFF Button
    buttonDot = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    buttonDot.frame = CGRectMake(dotXposition, 702, 20, 20);
    buttonDot.backgroundColor = [UIColor clearColor];
    UIImage *dotImage = [UIImage imageNamed:@"button.png"];
    [buttonDot setBackgroundImage:dotImage forState:UIControlStateNormal];
    UIImage *dotImagePress = [UIImage imageNamed:@"buttonPressed"];
    [buttonDot setBackgroundImage:dotImagePress forState:UIControlStateHighlighted];

    int dotIndex = buttonIndex + 20;
    buttonDot.tag = dotIndex;

}

I’m not sure what’s going on. The -(void) setNavAppearance method runs every time a new page loads and should theoretically set the desired appearance.

I’d appreciate any help anyone could offer.

Thanks

  • 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-06-17T16:09:45+00:00Added an answer on June 17, 2026 at 4:09 pm

    As already noted in my comment;

    Careful when using tag’s set to 0. If no tag is explicitely defined, zero is used. Hence anything that has no tag defined, will match zero.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I

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.