我希望 aUIToolbar在单击某个 时显示UITextField,但是在 中定义的工具栏@interface没有显示。这是我用于初始化并将其附加到文本字段的代码:
toolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
toolbar.barStyle = UIBarStyleBlackTranslucent;
toolbar.items = [NSArray arrayWithObjects:[[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleBordered target:self action:@selector(isDone:)], nil];
toolbar.hidden = NO;
[toolbar sizeToFit];
angleField.inputAccessoryView = toolbar;
有人可以看到我做错了什么吗?
PS 我在另一个项目中使用过类似的代码,并且它有效。这是代码:
 UIToolbar* numberToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
numberToolbar.barStyle = UIBarStyleBlackTranslucent;
numberToolbar.items = [NSArray arrayWithObjects:
                       [[UIBarButtonItem alloc]initWithTitle:@"Clear" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelNumberPad:)],
                       [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
                       [[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(doneWithNumberPad:)],
                       nil];
[numberToolbar sizeToFit];
changes.inputAccessoryView = numberToolbar;
哪里changes是UITextField