gpt4 book ai didi

ios4 - 如何将文本字段添加到工具栏

转载 作者:行者123 更新时间:2023-12-03 20:34:54 26 4
gpt4 key购买 nike

我有一个工具栏,我想在其中发布文本字段。我正在尝试使用以下代码,但它不起作用:

 UIBarButtonItem *customItem = [[UIBarButtonItem alloc] initWithTitle:@"Item" style:UIBarButtonItemStyleBordered target:self action:@selector(action:)];

UITextField *customItem1 = [[UITextField alloc] init];

NSArray *items = [NSArray arrayWithObjects: customItem, customItem1, nil];
[self setToolbarItems:items animated:YES];

最佳答案

工具栏项必须全部是 UIBarButtonItems。为了显示其他内容,您可以将 View 嵌入到项目中:

UIBarButtonItem *customItem1 = [[UIBarButtonItem alloc] initWithCustomView:view];
//view is the embedded view, in your case a UITextField

关于ios4 - 如何将文本字段添加到工具栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4467611/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com