我正在加載mapview。我在視圖的底部工具欄中創建了一個barbutton,並將其標識符設置爲pagecurl。正如所料,帶有頁面捲曲圖標的barbutton被加載。在此mapview中,我將移至另一個視圖,方法是單擊mapview中的註釋。然後我返回到地圖視圖。那時我的pagecurl barbutton圖標(pagecurl圖標)沒有顯示,我的barbutton寬度也減少了。我無法弄清楚問題所在。工具欄barbutton圖標(pagecurl)未加載
- (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];
}
}
一些代碼將是有益的。 – visakh7
我已經添加了代碼。我通過xib文件設置了barbutton的屬性。 –
在'viewWillAppear:'方法中移動您的代碼以設置工具欄。 –