簡體   English   中英

呈現的UIViewController模態顯示移到頂部

[英]UIViewController presented modally show up shifted to the top

我呈現了一個帶有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];

但是,頂部的條不可見,並且似乎向頂部移動(底部有一個空白空間)。

這是viewDidLoad,其中我在navigationItem上設置了Close按鈕

- (void)viewDidLoad
{
    [super viewDidLoad];

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

謝謝

如果您使用的是iPhone,請刪除

[import setModalPresentationStyle:UIModalPresentationFormSheet];

您應該添加一個導航欄,然后顯示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];

希望這可以幫助。 快樂的編碼:)

添加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];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM