Search code examples
iosuibarbuttonitem

UIBarButtonSystemItemPageCurl not showing, other system icon does


I am using a custom-made toolbar (UIToolBar), which shall display some items/buttons. One of them, however, does not show up. It is there, I can click it, it responds and fires the selector, but it is invisible.

This is how I build the toolbar:

spacer=    [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease];
menuItem=  [[[UIBarButtonItem alloc] initWithImage:[JASidePanelController defaultImage] style:UIBarButtonItemStylePlain target:(TabController*)self.parentViewController action:@selector(handleShowMenu)] autorelease];
addItem=   [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:[Storage currentStorage] action:@selector(showAddDialog)] autorelease];
titleItem= [[[UIBarButtonItem alloc] initWithTitle:[self pageTitle] style:UIBarButtonItemStylePlain target:nil action:nil] autorelease];

UIBarButtonItem* mapItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(toggleMapType)] autorelease];

NSArray* items= [NSArray arrayWithObjects:menuItem, spacer, titleItem, spacer, mapItem, addItem, nil];

toolbar= [[[UIToolbar alloc] initWithFrame:CGRectMake(0.0, 20.0, self.view.frame.size.width, TOOLBARHEIGHT)] autorelease];

[toolbar setItems:items];
[self.view addSubview:toolbar];

This will not display:

UIBarButtonItem* mapItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemPageCurl target:self action:@selector(toggleMapType)] autorelease];

Doesnt work

But replacing this line with:

UIBarButtonItem* mapItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(toggleMapType)] autorelease];

will make the item show.

Does work

Anyone knows why?


Solution

  • According to the UIBarButtonSystemItem docs,

    This bar button image can be used only for bar button items placed on toolbars.

    You're trying to place it on a navigation bar, which isn't allowed.

    It looks like this:

    Page curl

    That's not quite in line with iOS 7+ design guidelines, so that may also be an issue, but the docs don't say anything about deprecation, so it shouldn't be.