Toolbar barbutton icon(pagecurl) not loaded

I am loading a mapview. I have created a barbutton in the bottombar toolbar of the view, setting its identifier as pagecurl. As expected, a barbutton with page curl icon is loaded. From this mapview I move to anotherv view, by clicking on annotations in the mapview. And then I return to the mapview. At that time my pagecurl barbutton icon(pagecurl icon) is not displayed, and my barbutton width is also reduced. I am not able to figure out the problem.

- (void)viewDidLoad
{
    [super viewDidLoad];

    if(isSingleContactSelected)
    {
        [self.navigationController.navigationBar setBarStyle:UIBarStyleDefault];
        self.navigationItem.leftBarButtonItem = self.cancelButton   ;
        [self.cancelButton setTarget:self];
        [self.cancelButton setAction:@selector(onClose:)];

        [addressFieldSearchBar setFrame:CGRectMake(66, 0, 256, 44)];
        addressFieldSearchBar.delegate =self;

        [self.navigationController.navigationBar setBarStyle:UIBarStyleDefault];
        [self.navigationController.navigationBar addSubview:addressFieldSearchBar];

        [searchDirectionSegmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
        UIBarButtonItem *searchDirectionSegmentedButton = [[UIBarButtonItem alloc] initWithCustomView:searchDirectionSegmentedControl];

        flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
        NSArray *toolbarItems = [NSArray arrayWithObjects: compassButton , flexibleSpace, searchDirectionSegmentedButton, flexibleSpace, pageButton, nil];
        [self setToolbarItems:toolbarItems];

        self.navigationController.toolbarHidden = NO;
        [compassButton release];
        [pageButton release];
        [searchDirectionSegmentedControl release];

        mapView = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
        mapView.delegate=self; 

        [self.view addSubview:mapView]; 
    }
}

- (void)viewDidUnload{
    [super viewDidUnload];    
}

-(void) viewWillAppear:(BOOL)animated{
    if(isSingleContactSelected){
        [self.navigationController.navigationBar setHidden:NO];
        [self.navigationController.toolbar setHidden:NO];
        [self.navigationController.toolbar setBarStyle:UIBarStyleDefault];
        [self.addressFieldSearchBar setHidden:NO];
    }
}

-(void) viewWillDisappear:(BOOL)animated{
    if(isSingleContactSelected){
        [self.addressFieldSearchBar setHidden:YES];
        [self.navigationController.toolbar setHidden:YES];
    }
}

Answers


Though its a long shot, it could be something to do with the setHidden calls in your appear and disappear methods.

[self.navigationController.toolbar setHidden:YES];
[self.navigationController.toolbar setHidden:NO];

The best way to do this using UIViewController's "-setHidesBottomBarWhenPushed:" method.

Maybe try some NSLog() in -viewWillAppear:

// If pageButton is an instance variable
NSLog(@"%@",pageButton);

// Enumerate through all toolbar items.
// Check to see if NSLog output differs after pushing/popping this view controller.
for (UIBarButtonItem *item in [self.navigationController.toolbar.items])
{
    NSLog(@"%@",item);
}

Need Your Help

Visual Studio 2010 working directory

c# asp.net

I'm developing a C# asp.net web application. I'm basically done with it, but I have this little problem. I want to save xml files to the "Users" folder within my project, but if I don't psychically...

Remove entity and relations the correct way (JPA)

jpa entity dao

I have an entity Task and a dao for it: TaskDao. A Task entity has a ManyToOne mapping to Category. When I delete a Task, I also need to remove the Task from the collection in Category:

Detaching EF entities from DB context, removing their relations?

c# asp.net entity-framework serialization

public List<PRODUCT> GetProductsByProductcategory(decimal productCategoryKey)