質問

私のアプリを持っUITabBarControllerとUINavigationControllers初期化このような

UINavigationController *newsNavigationController = [[UINavigationController alloc] initWithRootViewController: newsViewControler];

newsViewControllerはUIViewController.私はボタンを押しtabbarにおいて、ナビゲーションアイテムのnewsViewControllerのタイトル、ナビゲーションバーはokです。のnewsViewControllerい方法を設定する呼びかけた後のinit.のセットアップ方法を設定しますこのようなタイトル [[self navigationItem] setTitle:[category_c title]];

の問題が、私のnewsViewControllerいtableView、タッチセルしたいの押しUIViewControllerの選択したニュース、ナビゲーションバーを示す。

のUIViewControllerして同じ設定する方法iセットアップのタイトルのようです。問題は、とについては記載しておりません。の項目がnullでない場合ることができるから電話 self.navigationItem.hidesBackButton = YES; で隠のbackbutton毎回のタイトルな表示します。

私が作成したとのニュースUIViewControllerのような場合、この細胞をタッチすると

if(newsViewController == nil){
        newsViewController = [[NewsViewController alloc] init];
        [newsViewController setup];
    }
    [self.navigationController pushViewController: newsViewController animated:YES];

の設定方法にnewsViewControllerようになります:

- (void) setup {
    self.navigationItem.hidesBackButton = YES;
    [self.navigationItem setTitle:@"my view"];
}

のnewsViewControllerしていまviewDidLoadし設定のタイトルがない。

  • (void)viewDidLoad{ ます。navigationItem.title=@"試験";【スーパー viewDidLoad];}

その後 [self.navigationController pushViewController: newsViewController animated:YES]; 書いてい [[self.navigationController.viewControllers objectAtIndex:0] setTitle:@"myTitle"]; のUIViewControllerが含まれるUITableViewのタイトルmyTitleの代わりにnewsViewControllerうに押された時に影響を与えてきた。

任意のポインタ?するのは納得がいかないタイトルが正しく設定されていない.

EDIT2:読んだ後にもう少しやって自分のコードデバッガの段階と比較するとrootviewcontrollersのchildViewControllersっ果のviewDidLoad法のchildViewControllerを設定します。title=@"タイトル"のnavigationItem作成しているのではなく、nil。のデバッガの時を拡大し_navigationItem変数の分野_navigationBarはnil後viewDidLoadのrootViewControllersのnavigationBarがNULLでない場合、タイトルがございます。を読み込みました場合には、navigationBarがnullの場合、タイトルは表示されます。イメージは僕が見た、debuger. altテキストhttp://img138.imageshack.us/img138/1513/picture2bq.png 現地に行って探します。

EDIT1:以下のコードは、次のとおりですparentViewController,firstChildViewController二ChildViewController.のparentViewControllerするときのみのタイトルはOKを押します。私のボタンを押navigationBarるbearbeitenAction->最初の子が押された(タイトルについては記載しておりません).のナビゲーションバーのfirstChildViewControllerいボタンが押下押新ViewControllerのスタック(secondChildViewController).タイトルのChildViewControllerはokです。私はプレスのタイトルのfirstChildViewControllerした。

parentViewController:

    //MARK: -
    //MARK: Initialization methods
    - (void) setup {
        dataManipulator = [[DataManipulation alloc] init];
        dataManipulator.delegate = self;

        [self.tabBarItem initWithTitle:[NSString stringWithFormat:@"%@",[category_c title]] image:[UIImage newImageFromResource:[category_c icon]] tag:0];

        searchResults = nil;
        companyDetailsPushed = NO;
    }

    //MARK: -
    //MARK: ViewControllerMethods
    // Implement loadView to create a view hierarchy programmatically, without using a nib.
    - (void) loadView {
        NSLog(@"WatchlistViewController: loadView");

        UIView *mainView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] applicationFrame].size.width, [[UIScreen mainScreen] applicationFrame].size.height)] autorelease];
        [mainView setBackgroundColor:[UIColor whiteColor]];
        mainView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
        mainView.contentMode = UIViewContentModeScaleToFill;
        [mainView setAutoresizesSubviews:YES];

            companiesTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 44, [[UIScreen mainScreen] applicationFrame].size.width, 322)];
        companiesTable.delegate = self;
        companiesTable.dataSource = self;
        [mainView addSubview:companiesTable];
        [companiesTable release];

            self.view = mainView;
    }

    - (void)viewDidLoad {
        [super viewDidLoad];
        if(![[category_c subtitle] isEqualToString:@""]) {
            self.title = [category_c subtitle];
        }
        else {
            self.title = [category_c title];
        }
    }

    - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

        if(companyDetailsViewController == nil) {
            companyDetailsViewController = [[CompanyDetailsScrollViewController alloc] init];
            [companyDetailsViewController setup];
        }

        [watchlistDoneBtn setHidden:TRUE];
        companyDetailsPushed = YES;

        if(viewMode == SearchViewMode)
            [companyDetailsViewController setCompany:[searchResults objectAtIndex:indexPath.row]];
        else if(viewMode == WatchlistViewMode)
            [companyDetailsViewController setCompany:[[[Financial_deAppDelegate sharedAppDelegate] watchlistCompanies] objectAtIndex:indexPath.row]];

        [[self navigationController] pushViewController:companyDetailsViewController animated:YES];
    }

- (void) bearbeitenAction:(UIButton *) sender {
    NSLog(@"Berbeiten btn was pressed");
    if(berbeitenViewController == nil){
        berbeitenViewController = [[BerbeitenViewController alloc] init];
        [berbeitenViewController setup];
    }
    [self.navigationController pushViewController:berbeitenViewController animated:YES];
}

firstChildViewController=berbeitenViewControllerのコード:

- (void) setup {
    self.navigationItem.hidesBackButton = YES;
}

// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
    NSLog(@"BerbeitenViewController: loadView");

    UIView *mainView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] applicationFrame].size.width, [[UIScreen mainScreen] applicationFrame].size.height)] autorelease];
    [mainView setBackgroundColor:[UIColor darkGrayColor]];
    mainView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    mainView.contentMode = UIViewContentModeScaleToFill;
    [mainView setAutoresizesSubviews:YES];

    berbeitenBackBtn = [[UIButton alloc] initWithFrame:CGRectMake(5, 23, 69, 36)];
    [berbeitenBackBtn setBackgroundImage:[UIImage newImageFromResource:@"back_btn.png"] forState:UIControlStateNormal];
    [berbeitenBackBtn addTarget:self action:@selector(popViewController:) forControlEvents:UIControlEventTouchUpInside];
    [berbeitenBackBtn setEnabled:TRUE];
    [self.navigationController.view addSubview:berbeitenBackBtn];
    [berbeitenBackBtn release];

    berbeitenAddBtn = [[UIButton alloc] initWithFrame:CGRectMake(260, 23, 55, 36)];
    [berbeitenAddBtn setBackgroundImage:[UIImage newImageFromResource:@"bearbeiten_add_btn.png"] forState:UIControlStateNormal];
    [berbeitenAddBtn addTarget:self action:@selector(addCompany:) forControlEvents:UIControlEventTouchUpInside];
    [berbeitenAddBtn setEnabled:TRUE];
    [self.navigationController.view addSubview:berbeitenAddBtn];
    [berbeitenAddBtn release];

    companiesTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] applicationFrame].size.width, 366)];
    companiesTable.delegate = self;
    companiesTable.dataSource = self;
    [mainView addSubview:companiesTable];
    [companiesTable release];

    self.view = mainView;
}

- (void)viewDidLoad {
    NSLog(@"BerbeitenViewController viewDidLoad");
    [super viewDidLoad];
    self.title = @"Edit watchlist";
}

//MARK: Buttons actions

- (void) popViewController:(UIButton *) sender {
    NSLog(@"Pop BerbeitenViewController");
    [self.navigationController popViewControllerAnimated:YES];
}

- (void) addCompany:(UIButton *) sender {
    NSLog(@"Berbeiten addCompany btn pushed");
    if(searchViewController == nil){
        searchViewController = [[SearchViewController alloc] init];
        [searchViewController setup];
    }
    [self.navigationController pushViewController:searchViewController animated:YES];
}

secondChildViewController=searchViewControllerコード

- (void) setup {
    self.navigationItem.hidesBackButton = YES;
}

// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
    NSLog(@"BerbeitenViewController: loadView");

    UIView *mainView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, [[UIScreen mainScreen] applicationFrame].size.width, [[UIScreen mainScreen] applicationFrame].size.height)] autorelease];
    [mainView setBackgroundColor:[UIColor darkGrayColor]];
    mainView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    mainView.contentMode = UIViewContentModeScaleToFill;
    [mainView setAutoresizesSubviews:YES];

    searchViewBackBtn = [[UIButton alloc] initWithFrame:CGRectMake(5, 23, 69, 36)];
    [searchViewBackBtn setBackgroundImage:[UIImage newImageFromResource:@"back_btn.png"] forState:UIControlStateNormal];
    [searchViewBackBtn addTarget:self action:@selector(popViewController:) forControlEvents:UIControlEventTouchUpInside];
    [searchViewBackBtn setEnabled:TRUE];
    [self.navigationController.view addSubview:searchViewBackBtn];
    [searchViewBackBtn release];

    self.view = mainView;
}


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"Edit Watchlist";
}
役に立ちましたか?

解決 3

ソースの問題の背景画像のためのnavigationBarい付加手法を用いたこのアドレス http://sebastiancelis.com/ .基本的には何が起こったように著者:

を使用しましたが簡単に 追加独自のsetBackgroundImage:方法 呼び出している場合を作成しま UINavigationBarや UINavigationController.この方法 だけで追加UIImageViewとして subviewのナビゲーションバーとして 送信するsubview、その superview.

しかし、使ってみればこのま 素早く見ることの ます。のUIImageViewがあ 見えるものは、当初の 正しいz-index. ただし、 押しやポップ、ビューのコントローラー ナビコントローラのスタック、 この背景画像には な背景になります。代わりに、 このブロックのタイトルやカーナビ バーボタンを押します。このレコード店ディスクユニオン かないままです。

を発見したときにはこのソリューションの変更の背景navigationBarに入っていて今でもそうでなかった..

いただき誠にありがとうござい。

他のヒント

編集#2

ってコードと思うので大丈夫です。るということだけが見える場所だと思いることを追加subviewのナビコントローラを利用する代わりに子コントローラのnavigationItem.は、いまだかつてみたことがないで行われます。各ViewControllerが UINavigationItem 性を表すビューコントローラで押し出されたナビゲーションバーです。読取るだけで、概要のドキュメンテーションにある。

そのNavigationItemはタイトルの左ボタンと右ボタンできるセット---いう設定のためのボタンプロパティが追加subviewsのナビコントローラーでやろうというファンキータイトルに...再度は、いまだかつてみたことがないだからできることを確認することができますように思いま、それは間違っています。のみを変更したりするためのボタンをUIBarButtonItemクラスです。ぜひ試してみてください.

独自の

ルートviewにコントローラはインデックス0の配列...だっこ

[[self.navigationController.viewControllers objectAtIndex:0] setTitle:@"myTitle"]

あくまでもそれらのルート。いす:

objectAtIndex:([self.navigationController.viewControllers count] - 1)

することにもなりやすいこのような設定をコントローラのviewWillAppear法。そのような検索、ナビコントローラの子どもたちのためには、正しいビューコントローラです。

武器agiは、dexで下がらないboxerぐ

編集 きみのみ設定のタイトルのinitメソッド:

-(id)init {
    if (self = [super init]) {
        self.title = @"My Title";
    }
    return self;
}

このように、このオブジェクトのinitメソッドを担当できることを初期化するオブジェクトの値である良いもの).

きに setup コンピュータやケーブル viewDidLoad 方法です。の viewDidLoad 要求されたときに呼び出されるの航項目で設定します。

設定のタイトルは、単に利用 self.title = @"my view"; まあらかじめご了承くださいタイトルを直接navigationItem.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top