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

  • Home
  • SEARCH
  • 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 6881041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:03:26+00:00 2026-05-27T05:03:26+00:00

Possible Duplicate: How can i add more than 10 buttons on a navigationbar in

  • 0

Possible Duplicate:
How can i add more than 10 buttons on a navigationbar in iphone application development?

I want to set an UIScrollView on a navigation bar which containing eight buttons and this navigation bar also containing leftbaritem and rightbaritem when i will press the next or previous button then scrollview have to scroll with this button because some of button will be out of the scrollview frame.

Until now i have made scroll view and buttons but problem is button are now displaying.Can anybody help me by giving an example or sending source code.

Thanks in Advance

EDIT

topToolBar = [UIToolbar new];
[topToolBar sizeToFit];
topToolBar.frame = CGRectMake(0,0, 280, 50);
topToolBar.barStyle = UIBarStyleBlackTranslucent;

segmentedControllerView = [[UIView alloc] initWithFrame:CGRectMake(5, 0, 280, 50)];
segmentedControllerView.clipsToBounds = YES;

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self 
           action:@selector(aMethod:)
 forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(0,0, 60.0, segmentedControllerView.frame.size.height -10);
button.clipsToBounds = YES;
[segmentedControllerView addSubview:button];

UIButton *button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button2 addTarget:self 
           action:@selector(aMethod2:)
 forControlEvents:UIControlEventTouchDown];
[button2 setTitle:@"Show View2" forState:UIControlStateNormal];
button2.frame = CGRectMake(60,0, 60.0, segmentedControllerView.frame.size.height - 10);
[segmentedControllerView addSubview:button2];

UIButton *button3 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button3 addTarget:self 
           action:@selector(aMethod3:)
 forControlEvents:UIControlEventTouchDown];
[button3 setTitle:@"Show View" forState:UIControlStateNormal];
button3.frame = CGRectMake(120,0, 60.0, segmentedControllerView.frame.size.height -10 );
[segmentedControllerView addSubview:button3];

UIButton *button4 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button4 addTarget:self 
           action:@selector(aMethod4:)
 forControlEvents:UIControlEventTouchDown];
[button4 setTitle:@"Show View" forState:UIControlStateNormal];
button4.frame = CGRectMake(180,0, 60.0, segmentedControllerView.frame.size.height -10 );
[segmentedControllerView addSubview:button4];

[topToolBar addSubview:segmentedControllerView];
self.navigationItem.titleView = topToolBar;

I am also close to the result but problem is when i am pressing the next or prev button then it moving over the next or prev button but it should be move under the view….

This is the animation code:

   -(void)previousBarButtonAction{

[UIView beginAnimations: @"moveField"context: nil];
[UIView setAnimationDelegate: self];
[UIView setAnimationDuration: 0.5];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
segmentedControllerView.frame = CGRectMake(segmentedControllerView.frame.origin.x - 50,
                                   segmentedControllerView.frame.origin.y,
                                   segmentedControllerView.frame.size.width,
                                   segmentedControllerView.frame.size.height);
[UIView commitAnimations];


}
-(void)nextBarButtonAction{

[UIView beginAnimations: @"moveField"context: nil];
[UIView setAnimationDelegate: self];
[UIView setAnimationDuration: 0.5];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
segmentedControllerView.frame = CGRectMake(segmentedControllerView.frame.origin.x + 50,
                              segmentedControllerView.frame.origin.y,
                              segmentedControllerView.frame.size.width,
                              segmentedControllerView.frame.size.height);
[UIView commitAnimations];

}
  • 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-27T05:03:27+00:00Added an answer on May 27, 2026 at 5:03 am

    I have solve this problem slightly different way….

    In viewDidLoad I have take a scrollView and called my function

    menuScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,320,40)];
    menuScrollView.showsHorizontalScrollIndicator = FALSE;
    menuScrollView.showsVerticalScrollIndicator = FALSE;
    menuScrollView.bounces = TRUE;
    
    
    [self createMenuWithButtonSize:CGSizeMake(70.0, 30.0) withOffset:20.0f noOfButtons:7];
    

    Then in my function i have created my menu buttons which will be look like buttons on a navigation bar

    -(void)createMenuWithButtonSize:(CGSize)buttonSize withOffset:(CGFloat)offset noOfButtons:(int)totalNoOfButtons{
    
    NSLog(@"inserting into the function for menu bar button creation"); 
    for (int i = 0; i < totalNoOfButtons; i++) {
    
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    
        [button addTarget:self action:@selector(mybuttons:) forControlEvents:UIControlEventTouchUpInside];
        if(i==0){
        [button setTitle:[NSString stringWithFormat:@"Dashboard"] forState:UIControlStateNormal];//with title
        }
        else if(i==1){
            [button setTitle:[NSString stringWithFormat:@"Order"] forState:UIControlStateNormal];//with title
        }
        else if(i==2){
            [button setTitle:[NSString stringWithFormat:@"Product"] forState:UIControlStateNormal];//with title
        }
        else if(i==3){
            [button setTitle:[NSString stringWithFormat:@"Customers"] forState:UIControlStateNormal];//with title
        }
        else if(i==4){
            [button setTitle:[NSString stringWithFormat:@"Content"] forState:UIControlStateNormal];//with title
        }
        else if(i==5){
            [button setTitle:[NSString stringWithFormat:@"Site Analysis"] forState:UIControlStateNormal];//with title
        }
        else if(i==6){
            [button setTitle:[NSString stringWithFormat:@"Store Settings"] forState:UIControlStateNormal];//with title
        }
        else if(i==7){
            [button setTitle:[NSString stringWithFormat:@"CMS Settings"] forState:UIControlStateNormal];//with title
        }
        button.frame = CGRectMake(i*(offset+buttonSize.width), 8.0, buttonSize.width, buttonSize.height);
        button.clipsToBounds = YES;
        button.showsTouchWhenHighlighted=YES;
        button.layer.cornerRadius = 0;//half of the width
        //button.layer.borderColor=[UIColor clearColor];
        button.layer.backgroundColor=[UIColor blueColor].CGColor;
        button.titleLabel.font = [UIFont systemFontOfSize:10];
        button.layer.borderWidth=0.0f;
        button.tag=i;
        [menuScrollView addSubview:button];
    }
    menuScrollView.contentSize=CGSizeMake((buttonSize.width + offset) * totalNoOfButtons, buttonSize.height);
    [self.view addSubview:menuScrollView];
    
    }
    

    and it solves…Happy Coding… :))

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

Sidebar

Related Questions

Possible Duplicate: How can I pre-set arguments in JavaScript function call? (Partial Function Application)
Possible Duplicate: Can I get more than 1000 records from a DirectorySearcher in Asp.Net?
Possible Duplicate: How can I add a Trace() to every method call in C#?
Possible Duplicate: How is possible add child to the specific node how i can
Possible Duplicate: Can I add custom methods/attributes to built-in Python types? In Ruby you
Possible Duplicate: How to add 30 minutes to a javascript Date object? I can
Possible Duplicate: How to call a JavaScript function from PHP? Can I add a
Possible Duplicate: visual c++ 2010 can't add resource file To add bitmap I should
Possible Duplicate: Can you add multiple jars in a jar file and then launch
Possible Duplicate: How can I add loading text/image to images that are still loading

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.