【发布时间】:2014-02-18 15:14:51
【问题描述】:
我正在向 UIView 添加工具栏,例如:
UIToolbar *toolbar = [[UIToolbar alloc] init];
toolbar.frame = CGRectMake(0, 0, 300, 44);
UIBarButtonItem *button1 = [[UIBarButtonItem alloc] initWithTitle:@"Send" style:UIBarButtonItemStyleDone target:self action:@selector(sendAction)];
UIBarButtonItem *button2=[[UIBarButtonItem alloc]initWithTitle:@"Cancel" style:UIBarButtonItemStyleDone target:self action:@selector(cancelAction)];
[toolbar setItems:[[NSArray alloc] initWithObjects:button1, nil]];
[toolbar setItems:[[NSArray alloc] initWithObjects:button2, nil]];
[self.view addSubview:toolbar];
但是按钮总是处于禁用状态..我不知道为什么总是会发生这种情况。我也清理了我的项目。
【问题讨论】:
-
“禁用表单”是什么意思——你的意思是点击按钮不会运行操作方法吗?你看到两个按钮了吗?我认为您设置项目的代码应该是“[toolbar setItems:@[button1, button2];”。
标签: ios6 uiview uibarbuttonitem toolbar