0

presentModalViewController:animated で UIViewController を提示しています。

    CMImportViewControlleriPhone *import = [[CMImportViewControlleriPhone alloc] initWithNibName:@"Import-iPhone" bundle:nil];
    [import setModalPresentationStyle:UIModalPresentationFormSheet];
    [import setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
    [self presentModalViewController:import animated:YES];
    [import release];

ただし、上部のバーは表示されず、上部にシフトしているように見えます (下部に空のスペースがあります)。

これは、navigationItem に閉じるボタンを設定した viewDidLoad です。

- (void)viewDidLoad
{
    [super viewDidLoad];

    closeButton = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(closeButtonPushed:)];
    [[self navigationItem] setRightBarButtonItem:closeButton];
    [closeButton release];
}

ありがとう

4

3 に答える 3

0

iPhoneを使用している場合は、削除してください

[import setModalPresentationStyle:UIModalPresentationFormSheet];
于 2012-09-11T09:20:42.467 に答える
0

UIBarButtonItemを追加すると、NavigationControllerはnilになり、navigationBarもnilになります。したがって、navigationItemでは機能しません。

closeButton = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(closeButtonPushed:)];
[[self navigationItem] setRightBarButtonItem:closeButton];

インポートオブジェクトのNavigationControllerを追加し、それを提示する必要があります。

CMImportViewControlleriPhone *import = [[CMImportViewControlleriPhone alloc] initWithNibName:@"Import-iPhone" bundle:nil];
[import setModalPresentationStyle:UIModalPresentationFormSheet];
[import setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:import];
[self presentModalViewController:import animated:YES];
[import release];
[nc release];
于 2012-09-11T09:56:47.117 に答える
0

ナビゲーション バーを追加してから modalView を提示する必要があります

CMImportViewControlleriPhone *obj = [[CMImportViewControlleriPhone alloc] initWithNibName:@"Import-iPhone" bundle:nil];
[obj setDelegate:self];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:obj];
[self presentModalViewController:navigationController animated:YES];
[obj release];
[navigationController release];

お役に立てれば。幸せなコーディング:)

于 2012-09-11T09:28:13.097 に答える