如何将 Decimal Pad 的 Done 按钮移到 iOS 的右侧?
How do I bring the Done button of Decimal Pad to the right side on iOS?
On iOS - 当我们使用 Decimal Pad 作为文本字段的键盘类型时,虚拟键盘默认在键盘的左上角显示一个完成按钮。无论如何要将它自定义到键盘的右上角?
我发现这段代码是用来显示键盘上的按钮的。但是找不到任何方法将其移动到右侧。
谢谢。 :)
您需要在工具栏 完成按钮之前添加一个 UIBarButtonSystemItemFlexibleSpace
;这将填满可用 space 并将按钮向右移动。没有看到你的代码,它应该像这样工作:
NSMutableArray *items = [[NSMutableArray alloc] init];
[items addObject:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]];
[items addObject:[[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonItemStylePlain
target:self
action:@selector(doneButtonTapped:)];];
[toolbar setItems:items];
On iOS - 当我们使用 Decimal Pad 作为文本字段的键盘类型时,虚拟键盘默认在键盘的左上角显示一个完成按钮。无论如何要将它自定义到键盘的右上角?
我发现这段代码是用来显示键盘上的按钮的。但是找不到任何方法将其移动到右侧。
谢谢。 :)
您需要在工具栏 完成按钮之前添加一个 UIBarButtonSystemItemFlexibleSpace
;这将填满可用 space 并将按钮向右移动。没有看到你的代码,它应该像这样工作:
NSMutableArray *items = [[NSMutableArray alloc] init];
[items addObject:[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]];
[items addObject:[[UIBarButtonItem alloc] initWithTitle:@"Done"
style:UIBarButtonItemStylePlain
target:self
action:@selector(doneButtonTapped:)];];
[toolbar setItems:items];