我正在加载一个mapview。我在视图的bottombar工具栏中创建了一个barbutton,将其标识符设置为pagecurl。正如所料,加载了带有页面卷曲图标的条形码。从这个mapview我通过点击mapview中的注释移动到另一个视图。然后我回到mapview。那时我的pagecurl barbutton图标(pagecurl图标)没有显示,我的barbutton宽度也减少了。我无法弄清楚问题。
- (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];
}
}
答案 0 :(得分:1)
虽然它很长,但它可能与你的出现和消失方法中的setHidden调用有关。
[self.navigationController.toolbar setHidden:YES];
[self.navigationController.toolbar setHidden:NO];
使用UIViewController的“-setHidesBottomBarWhenPushed:”方法执行此操作的最佳方法。
也许在-viewWillAppear:
中尝试一些NSLog()// 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);
}
答案 1 :(得分:0)
setHidesBottomBarWhenPushed
方法可以解决问题。