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

How to find all substrings that match a pattern in Rebol

regex rebol

Here, I'm attempting to find all matches of a pattern in a string:

Register a custom org.osgi.resource.Resource

java osgi

How can I register my own OSGi-resource (org.osgi.resource .Resource, not a file in a bundle), which can define capabilities and requirements.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.