相关疑难解决方法(0)

将UILabel添加到UIToolbar

我正在尝试在工具栏中添加标签.按钮效果很好,但是当我添加标签对象时,它会崩溃.有任何想法吗?

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];
Run Code Online (Sandbox Code Playgroud)

iphone uibarbuttonitem ios

96
推荐指数
4
解决办法
10万
查看次数

标签 统计

ios ×1

iphone ×1

uibarbuttonitem ×1