-1

もともと、ナビゲーション コントローラーのないカスタム NavigationBar がありました。スライドメニューがあります。

ホーム画面には、リスト付きのテーブルビューがあります。このリストにアイテムを追加できるようにしたいと思います。そのため、後からナビゲーション コントローラーを追加する必要がありました。ナビゲーション コントローラーをストーリーボードに追加し、それをメインのビュー コントローラー [リストのあるもの] にリンクしました。次に、View Controller をドラッグしました。バー ボタン アイテムをナビゲーション アイテムにドロップし、最近追加されたビュー コントローラーにプッシュしました。

アプリを実行しましたが、アプリにナビゲーション バーやナビゲーション アイテムがまったく表示されません。もともと、カスタム ナビゲーション バーがありました。

ここで何が起こっているのかよくわかりません。助けてくれてありがとう。

- (void)customizeAppearance {
    UIImage *NavBG = [UIImage imageNamed:@"nav bar.png"];
    [[UINavigationBar appearance] setBackgroundImage:NavBG forBarMetrics:UIBarMetricsDefault];

私の絵コンテ

.m からのビュー コントローラー コードの初期化

#import "initViewController.h"
#import "ECSlidingViewController.h"
#import "MenuViewController.h"

@interface initViewController ()

@end

@implementation initViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.topViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Main"];

}

.h から

#import "ECSlidingViewController.h"

@interface initViewController : ECSlidingViewController

@end

main.m から

#import "MainViewController.h"

#import "ECSlidingViewController.h"
#import "MenuViewController.h"


@interface MainViewController ()

@end

@implementation MainViewController
{
    NSArray *toDoList;
    NSIndexPath *selectedIndexPath;
} 

@synthesize menuBtn;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

main.h から

#import <UIKit/UIKit.h>


@interface MainViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
{

}

@property (strong, nonatomic) UIButton *menuBtn; // go to MenuViewController.m and synthesize

@end

2番目のview controller.mファイル

    #import "SecondViewController.h"
#import "ECSlidingViewController.h"
#import "MenuViewController.h"

@interface SecondViewController ()

@end

@implementation SecondViewController
@synthesize menuBtn;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Below is the same stuff pasted from MainViewController.m



    // Do any additional setup after loading the view.
    self.view.layer.shadowOpacity = 0.75f;
    self.view.layer.shadowOpacity = 10.0f;
    self.view.layer.shadowColor = [UIColor blackColor].CGColor;



    if (![self.slidingViewController.underLeftViewController isKindOfClass:[MenuViewController class]]) {
        self.slidingViewController.underLeftViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];

    }

    [self.view addGestureRecognizer:self.slidingViewController.panGesture];

    self.menuBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    menuBtn.frame = CGRectMake(8, 10, 34, 24);
    [menuBtn setBackgroundImage:[UIImage imageNamed:@"menuButton.png"] forState:UIControlStateNormal];
    [menuBtn addTarget:self action:@selector(revealMenu:) forControlEvents:UIControlEventTouchUpInside];


    [self.view addSubview:self.menuBtn];
}

ここに私が使用するすべての配列があります

すべての配列

4

1 に答える 1

-1

表示している画像から、VC の左に開始矢印があるようには見えません。その場合は、SB に移動し、Nav コントローラーをクリックし、右側の属性インスペクターに移動し、下にスクロールして、「Is initial View Controller」を確認します。

これがそれに答えることを願っています。

更新:コードを推測すると、不変の NSArray を変更しようとしています。宣言を NSMutableArray *toDoList に変更します。

于 2013-02-05T02:43:39.283 に答える