我只想在一行中创建多个工具栏项,我做了什么...
NSMutableArray *barButtonArray = [[NSMutableArray alloc] init];
for (int i=0; i<[[State getSubCategoryids] count]; i++) {
NSString *nameString = [NSString stringWithFormat:@"%@",[[State getSubCategoryNames] objectAtIndex:i]];
NSLog(@"nameString: %@", nameString);
UIBarButtonItem *customBarButton = [[UIBarButtonItem alloc] initWithTitle:nameString style:UIBarButtonItemStyleBordered target:nil action:@selector(productImages)];
UIBarButtonItem *flexItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil
action:nil];
[barButtonArray addObject:customBarButton];
[barButtonArray addObject:flexItem];
[flexItem release];
[customBarButton release];
}
for (int i = 0; i<[barButtonArray count]; i++) {
NSLog(@"barbutton items for loop");
NSArray *items = [NSArray arrayWithObjects:[barButtonArray objectAtIndex:i],nil];
NSLog(@"items: %@", items);
[toolbar setItems:items animated:NO];
}
但它没有在工具栏中显示任何内容......有什么建议......?