开发者

How to add a textField to a toolbar

开发者 https://www.devze.com 2023-01-31 14:15 出处:网络
I have a toolbar where I want to post a textField. I\'m trying with the following code but it doesn\'t work:

I have a toolbar where I want to post a textField. I'm trying with the following code but it doesn't work:

 UIBarButtonItem *customItem = [[UIBarButtonItem alloc] initWithTitle:@"Item" style开发者_StackOverflow社区:UIBarButtonItemStyleBordered target:self action:@selector(action:)];

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

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


The toolbar items must all be UIBarButtonItems. In order to display something else, you embed a view into the item:

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

精彩评论

暂无评论...
验证码 换一张
取 消