UIBarButtonItem Not resizing to fit word

Discussion in 'iOS Programming' started by newtoiphonesdk, Mar 29, 2012.

  1. macrumors 6502a

    Joined:
    Jul 30, 2010
    #1
    I have a Table View set up for the iPad. In the MainWindow-iPad.xib I have a navigation controller, with the Table View Class as the Root View Controller. On the .xib I have a Navigation Bar, View Controller with class of Table View and NIB of Table View. I then have a navigation item, with two buttons. One button reads Archive and is on the left hand side. The other button contains a UIProgressView. I also have placed a label on the navigation bar for when downloads are present it will show name of download, and progressview will be unhidden and show progress of download. However, on the iPad, the word Archive appears as Ar...ve. I have a feeling it is due to either the label or the Progress Bar being too wide, and not giving any room to the BarButtonItem for Archive, but I can't figure out why. ProgressView is added in xib, Label is added in viewDidLoad code:
    Code:
    progress.hidden = YES;
        CGRect frame = CGRectMake(600, -14, 170, 44);
        downloadlabel = [[UILabel alloc]initWithFrame:frame];
        downloadlabel.textAlignment =  UITextAlignmentCenter;
        downloadlabel.textColor = [UIColor blackColor];
        downloadlabel.backgroundColor = [UIColor clearColor];
        downloadlabel.font = [UIFont fontWithName:@"Arial Rounded MT Bold" size:(18.0)];
    
    I have tried making frame (600, -14, 70, 44) but the button still shortens the button title. Any ideas?
     
  2. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #2
    How do you add the label to the navbar? Can you show a screenshot of the top of the screen with the navbar?
     
  3. newtoiphonesdk, Mar 29, 2012
    Last edited: Mar 29, 2012

    thread starter macrumors 6502a

    Joined:
    Jul 30, 2010
    #3
    I add the label when a file is being downloaded:
    Code:
    - (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
    
    self.nameit = entry.articleTitle;
        downloadlabel.text = [NSString stringWithFormat:@"%@", nameit];
        [thebar addSubview:downloadlabel];
    //some code removed
    }
    [​IMG]

    And during download:
    [​IMG]
     

    Attached Files:

  4. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    UIBarButtonItem has a possibleTitles property. This is a list of titles that might be used. It doesn't resize itself if you set a title at a later time that's not in its list of possibleTitles.

    UINavigationBar has a titleView property that is meant to be used to add a view to its center. I think I'd use that rather than addSubView to add a label.
     
  5. thread starter macrumors 6502a

    Joined:
    Jul 30, 2010
    #5
    So, are you saying I should or shouldn't use possibleTitles property? Sounds like if I set something NOT in its possibleTitles that it should NOT resize itself, as it is doing now...
     
  6. macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #6
    Right. You should use the possibleTitles property if you can.
     

Share This Page