0
我想要一個UIToolbar
顯示出來,當我點擊某個UITextField
,但工具欄,在@interface
定義,沒有顯示出來。 這是我的初始化和其連接到文本字段代碼:UIToolbar沒有顯示
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;
有人可以看到我在做什麼錯?
P.S.我在另一個項目中使用了類似的代碼,並且它工作。 下面是代碼:
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
你有代表爲它設置? – Jatin
我對此不太熟悉。我使用的代碼在另一個項目中幾乎相同,並且工作正常。我也可以發佈該代碼。 – Jeeter
我沒有在那裏看到一個'-addSubview:'。 – CodaFi