ios - UIBarButtonItem 没有出现
<p><p>我有一个问题,当 View 被加载时,它会加载 UIBarButtonItem,但是我必须在“mostra_filtro_btn”中将它设置为 nil,但是在“load_map”中我必须再次设置它,但它没有不出现。
这是我的代码:</p>
<pre><code>//
//FirstViewController.m
//House Finder
//
//Created by Giovanni Poli on 12/05/15.
//Copyright (c) 2015 Giovanni Poli. All rights reserved.
//
#import "MapViewController.h"
#import <QuartzCore/QuartzCore.h>
#import "Reachability.h"
#import "UIKit/UIKit.h"
#import <Foundation/Foundation.h>
#import "FiltroViewController.h"
@interface MapViewController ()
@end
@implementation MapViewController
@synthesize filtro_controller,overlay_filtro_counter,mappa_controller;
-(void)load_map{
NSLog(@"load_map");
;
;
;
UIBarButtonItem *Button = [ initWithTitle:@"Filtro" style:UIBarButtonItemStyleBordered target:self action:@selector(mostra_filtro_btn:)];
;
, NSForegroundColorAttributeName,nil]forState:UIControlStateNormal];
self.navigationItem.rightBarButtonItem = Button;
}
- (id) init{
filtro_controller = [init];
;
;
return self;
}
- (void)viewDidLoad {
self.title = @"Mappa";
self.navigationItem.title = @"House Finder";
self.navigationController.navigationBar.translucent = FALSE;
UIBarButtonItem *Button = [ initWithTitle:@"Filtro" style:UIBarButtonItemStyleBordered target:self action:@selector(mostra_filtro_btn:)];
;
, NSForegroundColorAttributeName,nil]forState:UIControlStateNormal];
self.navigationItem.rightBarButtonItem = Button;
NSString *filePath = [ pathForResource:@"data" ofType:@"json"];
NSData *content = [ initWithContentsOfFile:filePath];
NSDictionary *json = ;
NSArray * json_all = ;
mapView = [initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height-40)];
mapView.delegate = self;
mapView.showsUserLocation = NO;
mapView.userInteractionEnabled = YES;
CLLocationCoordinate2D annotationCoord;
self.view.userInteractionEnabled = YES;
NSDictionary * temp;
for (id object in json_all) {
temp = object[@"titolo"];
annotationCoord.latitude = floatValue];
annotationCoord.longitude = floatValue];
MKPointAnnotation *annotationPoint = [ init];
annotationPoint.coordinate = annotationCoord;
annotationPoint.title = object[@"titolo"];
annotationPoint.subtitle = object[@"agenzia"];
;
}
animated:YES];
;
;
}
- (IBAction) mostra_filtro_btn: (id)sender{
NSLog(@"mostra_filtro_btn");
self.navigationItem.rightBarButtonItem = nil;
filtro_controller = [init];
;
;
}
- (MKAnnotationView *)mapView:(MKMapView *)mapViews viewForAnnotation:annotation{
if (annotation == mapViews.userLocation) return nil;
MKPointAnnotation * temp = annotation;
MKAnnotationView * m = [ initWithAnnotation:annotation reuseIdentifier:@"casa"];
m.canShowCallout = YES;
m.enabled = YES;
m.userInteractionEnabled = YES;
NSString * icon_file = ;
m.image = ;
return m;
}
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view{
NSLog(@"overlay prezzo");
}
- (void)didReceiveMemoryWarning {
;
}
@end
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>使用以下代码将导航项设置为 nil,以便它可以隐藏在您想要的任何位置</p>
<pre><code>;
;
</code></pre></p>
<p style="font-size: 20px;">关于ios - UIBarButtonItem 没有出现,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/30214596/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/30214596/
</a>
</p>
页:
[1]