-2

ナビゲーションコントローラーを稼働させようとすると、ひどい問題が発生します。

基本的には、新しいビューをコントローラーにプッシュして、戻るボタンなどを押すことができるようにしたいと思います。

これが私がソファに持っているコードです:

TestAppDelegate.h:

#import <UIKit/UIKit.h>

@interface TestAppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end

TestAppDelegate.m:

#import "TestAppDelegate.h"

@implementation TestAppDelegate

@synthesize window = _window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor greenColor];
    [self.window makeKeyAndVisible];
    return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application
{
    /*
     Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
     Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
     */
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    /*
     Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 
     If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
     */
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    /*
     Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
     */
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    /*
     Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
     */
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    /*
     Called when the application is about to terminate.
     Save data if appropriate.
     See also applicationDidEnterBackground:.
     */
}

@end

しかし、私は今何をしますか?

NavigationControllerを保持する.xibファイルはどこに置くのですか?

4

5 に答える 5

1

これがUINavigationControllerクラスリファレンスです。ナビゲーションコントローラーを利用するいくつかのサンプルプロジェクトがリンクされています。それらをダウンロードして、どのように使用するかを確認してください。

于 2012-06-26T15:11:10.237 に答える
0

xcodeでストーリーボード機能を使用します。これにより、NavigationControllerをストーリーボードにドラッグアンドドロップするのと同じくらい簡単になります。

このリンクは私を大いに助けました。

于 2012-06-26T15:13:25.297 に答える
0

チュートリアルを見つけて実行するだけです。このように:

http://mobileorchard.com/how-to-make-an-iphone-app-part-4-navigation-controller/

于 2012-06-26T15:13:28.127 に答える
0

新しいファイルを作成>UIViewControllerサブクラス>ユーザーインターフェイスをXibで確認

#import <UIKit/UIKit.h>

@class WhatEverFileNameClass
@interface TestAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) WhatEverFileNameClass *viewController;

@end

.m

#import "TestAppDelegate.h"

@implementation TestAppDelegate

@synthesize window = _window;
@synthesize viewController = _viewController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[WhatEverFileNameClass alloc] initWithNibName:@"WhatEverFileNameClass" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
于 2012-06-26T15:14:19.313 に答える
0

最初にビューコントローラを作成します([新しいファイル]>[UIViewController]サブクラス>[Xibでユーザーインターフェイスを確認])

次に、セットアップしますUINavigationController

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    ViewController *vc = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil];
    UINavigationController *navController=[[UINavigationController alloc]initWithRootViewController:vc];
    self.window.rootViewController = navController;
    [self.window makeKeyAndVisible];
    return YES;

}
于 2012-06-26T15:19:59.580 に答える