我正在向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];
但按钮总是处于禁用状态..我不知道为什么会这样。我也清理了我的项目。
答案 0 :(得分:0)
NSArray * toolbarItems = [NSArray arrayWithObjects: button1,button2,nil]; [self.toolbar addsubview:toolbaritems
添加此行代码