Adding a UILabel to a UIToolbar

Posted by Boolean on Stack Overflow See other posts from Stack Overflow or by Boolean
Published on 2008-12-02T09:23:11Z Indexed on 2010/12/30 1:54 UTC
Read the original article Hit count: 152

Filed under:
|

I'm trying to add a label to my toolbar. Button works great, however when I add the label object, it crashes. Any ideas?

UIBarButtonItem *setDateRangeButton = [[UIBarButtonItem alloc] initWithTitle:@"Set date range"
                                                                       style:UIBarButtonItemStyleBordered
                                                                      target:self
                                                                      action:@selector(setDateRangeClicked:)];

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(5, 5, 20, 20)];
label.text = @"test";

[toolbar setItems:[NSArray arrayWithObjects:setDateRangeButton,label, nil]];

// Add the toolbar as a subview to the navigation controller.
[self.navigationController.view addSubview:toolbar];

// Reload the table view
[self.tableView reloadData];

© Stack Overflow or respective owner

Related posts about iphone

Related posts about cocoa-touch