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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:44:08+00:00 2026-05-26T14:44:08+00:00

Q1. I have three controls: UILabel , UIButton , and UILabel in a single

  • 0

Q1. I have three controls: UILabel, UIButton, and UILabel in a single line. I want to programmatically arranged them one after another in a line, without any gaps (similar to Java/Android “Flowlayout” layout), because length of text on each control will change due to the user actions. What is the best/easiest way to achieve “Flowlayout” layout programmatically?

Q2. Related to above, I want each control to resize automatically when the text change due to user actions, so the full text remains visible.

Thanks in advance.

//Edited 11/12/2011

Here is how I plan to achieve horizontal “flow layout” of controls that are contained in viewArray:

-(void) doHorizontalFlowLayout:(NSArray *) viewArray
{
        if(viewArray == nil || viewArray.count <=1
            return; //get out of here, no need to continue

        UIView *v0= (UIView *) [viewArray objectAtIndex:0]; // first view
        CGRect frame0 = v0.frame;

        CGFloat sumWidth= 0;
        for(int i=1; i < viewArray.count; i++)
        {
            UIView *thisView= (UIView*) [viewArray objectAtIndex:i];
            sumWidth = sumWidth+ v0.frame.size.width;
            CGRect nextFrame= CGRectMake(frame0.origin.x
                    +sumWidth, thisView.frame.origin.y,
                     thisView.frame.size.width, thisView.frame.size.height);
            thisView.frame= nextFrame;
            //the above works for 2 views only. For more than 2 views - reset v0 to point to the ith view
            v0 = (UIView*) [viewArray objectAtIndex:i];

        }
 }
  • 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-26T14:44:09+00:00Added an answer on May 26, 2026 at 2:44 pm

    Was just struggling with this — here is my solution:

    There’s no “flow layout” concept in iOS, so you have to calculate the widths of each control manually and place them absolutely in the parent container. UILabels are a bit different than buttons, as the only way to determine the content size is with the [NSString sizeWithFont:...] method. See here for an example.

    In your case, you’ll have to listen for when user interaction is complete on whichever element is changing, and use the [UIView setNeedsDisplay] (http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instm/UIView/setNeedsDisplay) method to redrawn the view and subviews.

    This is much more difficult than it needs to be, IMHO.

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

Sidebar

Related Questions

In VB.net 3.5 SP1 I have a Windows Form with three DataGridView controls. One
I have three hyperlinks, I want to position them near the right edge of
I have one index.html page and on this page I have three controls; one
1-I have three user controls. 2-I added them to AJAX TabContainer on my default.aspx
I have three TextBox controls on the page <asp:TextBox ID=TextBox1 runat=server AutoPostBack=True OnTextChanged=TextBox_TextChanged TabIndex=1>
So we have three FLEX controls hosted within a JBOSS server instance, and an
I have a web page that uses three controls to allow a user to
i have a table (System.Web.UI.WebControls). each row does have three cells. in cells' controls
I have a .aspx page that loads three separate .ascx controls to represent adding,
I have a ASP.Net Menu Control with three levels and flyouts enabled. I want

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.