标签: uinavigationcontroller

将正确的"完成"按钮(UIBarButtonItem)添加到UINavigationController

我在这里看到一个类似的问题:如何向UINavigationController添加一个右键?(除其他外)但它不是我想要做的,他们不解决我的问题.

基本上,我已经创建了一个名为WebViewViewController的UIViewController,其上有一个UIWebView,它将使用presentModalViewController显示.基本上它是一个迷你Web浏览器,用于显示网页,同时将用户保留在应用程序中,而不是启动Safari.

viewController执行以下操作以使其显示...并且"完成"按钮旨在提供关闭浏览器的位置.

-(IBAction)visitFacebook {
    WebViewViewController *rootController = [[WebViewViewController alloc] init];
    rootController.webURL = @"http://www.facebook.com/";
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootController];
    UIBarButtonItem *doneButton = [[UIBarButtonItem alloc ] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(done:)];

    [navigationController.navigationItem setRightBarButtonItem:doneButton animated:YES];
    [navigationController.navigationItem setTitle:@"Facebook"];

    if (rootController) {
        [self presentModalViewController:navigationController animated:YES];
    }

    [doneButton release];
    [rootController release];
}
Run Code Online (Sandbox Code Playgroud)

不幸的是,"完成"按钮没有显示..我出错的任何想法?

iphone uinavigationcontroller uibarbuttonitem ios

6
推荐指数
3
解决办法
2万
查看次数

viewDidAppear在iOS5中调用了两次

我正在开发一个带有UINavigatorController的应用程序.我在第二个推送的viewController中使用viewDidAppear方法来查找外部服务器中的信息.

好.虽然iOS5在开始时运行良好,但我意识到在iOS4.3中没有调用viewDidAppear所以我把这段代码放在根目录中:

- (void)navigationController:(UINavigationController *)navigationController 
       didShowViewController:(UIViewController *)viewController animated:(BOOL)animated 
{
    [viewController viewDidAppear:animated];
}
Run Code Online (Sandbox Code Playgroud)

此后,该应用程序开始在iOS4.3中正常运行.然而,在iOS5中没有,因为它调用了两次viewDidAppear(最初被调用的那个和来自的那个navigationController:didShowViewController:animated:)

如果只调用一次viewDidAppear,我该怎么办?

非常感谢你

uinavigationcontroller viewdidappear ios ios5

6
推荐指数
1
解决办法
2575
查看次数

UINavBar似乎在其他按钮上有一个不可见的图层

我创建了一个带有像facebook这样的侧边菜单的应用程序.我有一个根视图控制器,它自己添加一个视图,然后当用户按下"菜单"按钮时,它将滑动视图,以便您可以看到菜单.

我的问题是,当视图首次加载时,看起来UINavBar大约比它应该低20个像素左右.(下面的图像看起来有点偏离中心,因为它是一个模态水平翻转)

在此输入图像描述

然后,当模态转换完成时,它会自动调整自身并向上移动到该状态栏下方.

在此输入图像描述

以下是按"菜单"按钮时发生的情况的屏幕截图.它将顶视图滑动到右侧

在此输入图像描述

正如您在上面的图像中看到的那样,我将左箭头和右箭头框架背景设置为红色,这样我就可以看到可点击/可点击区域的位置.我有另一张图像,我在上面画了一条蓝线,如果我点击蓝线或上面那么它就不会触发右箭头.如果我点击左侧相同的一般区域,菜单按钮将会触发.我能够在模拟器和移动设备上重现这一点(所以我不会用手指按钮).

在此输入图像描述

在我看来,由于导航栏的加载低于iPhone应该认为它仍处于该位置,因此当我在UIButton框架内单击时,它仍然触发菜单而不触发箭头选择器.如果我在箭头中间直接点击,它会触发箭头选择器,但只是图像外的一点点,它不会触发箭头选择器.

这是我的RootViewControllerviewDidLoad

AppointmentViewController *appointmentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"AppointmentViewController"];
NSLog(@"B: %@",NSStringFromCGRect(appointmentViewController.view.frame));
self.navController = [[UINavigationController alloc] initWithRootViewController:appointmentViewController];
NSLog(@"B2: %@",NSStringFromCGRect(appointmentViewController.view.frame));
NSLog(@"Nav Bounds: %@",NSStringFromCGRect(self.navController.view.frame));
NSLog(@"Bounds: %@",NSStringFromCGRect(self.contentView.bounds));
self.navController.view.frame = self.contentView.bounds;
NSLog(@"Nav Bounds2: %@",NSStringFromCGRect(self.navController.view.frame));
[self addShadowToMenu];
[self.contentView addSubview:self.navController.view];
Run Code Online (Sandbox Code Playgroud)

RootViewController日志

2012-04-30 12:24:44.533 My-App[19929:fb03] B: {{0, 20}, {320, 460}}
2012-04-30 12:24:44.535 My-App[19929:fb03] B2: {{0, 20}, {320, 460}}
2012-04-30 12:24:44.535 My-App[19929:fb03] Nav Bounds: {{0, 0}, {320, 480}}
2012-04-30 12:24:44.535 My-App[19929:fb03] Bounds: {{0, 0}, {320, 460}}
2012-04-30 12:24:44.535 My-App[19929:fb03] Nav Bounds2: {{0, …
Run Code Online (Sandbox Code Playgroud)

objective-c uinavigationbar uinavigationcontroller ios5

6
推荐指数
1
解决办法
388
查看次数

将RootviewController更改为导航控制器

我是iPhone新手,

我想改变我的Rootviewcontroller新课程并将其转换为导航控制器.

这是我的代码片段,

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


    UINavigationController *navigationController=[[UINavigationController alloc] initWithRootViewController:detailViewController];
    [self.window addSubview:navigationController.view];

    [self.window makeKeyAndVisible];


    return YES;
}
Run Code Online (Sandbox Code Playgroud)

我SIGABRT说了'adding a root view controller <NewClass: 0x6a8dd50> as a child of view controller:

iphone uinavigationcontroller ipad ios rootview

6
推荐指数
1
解决办法
1万
查看次数

以编程方式立即解除UINavigation视图和模态视图

我在这个网站上尝试了几个答案,但似乎没有一个与我的问题有关

我有一个MasterDetail应用程序,它有两种类型的segues我正在使用.当您按下详细视图上的按钮时,它会使用推送segue并将另一个详细视图推送到该视图上.在新的detailview(刚推入的那个)中,有一个按钮,它使用模态segue调用另一个UIView(表单).

我所试图做的是当用户选择一排,一个UIAlertView中会出现一个显示的消息,而在同一时间(不一定是在同一时间)解聘的UIViewController的(模式),并返回来自推动的Viewcontroller.基本上,我需要能够解雇所有的viewcontrollers,一个模态和一个push(nav),以便视图返回到他们开始的原始主屏幕.

我有UIAlertView工作正常,我可以通过使用,[self.dismissViewControllerAnimated:YES completion:nil];但我不知道如何解雇下一个Viewcontroller(在导航控制器中)解雇模态viewcontroller .使用此:[self.navigationController popToRootViewControllerAnimated:NO];不起作用.

这是我想要调用函数删除所有视图的地方:

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

    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlWithIDAndChallenge];

    NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:request delegate:self];

    UIAlertView *message = [[UIAlertView alloc] initWithTitle@"Started" message:@"The challenge has begun!" delegate:nil cancelButtonTitle:@"OK!" otherButtonTitles:nil];

    [message show]

    //right here is where I would normally dismiss the modal VC
    //here is where I would like to dismiss all VC

}
Run Code Online (Sandbox Code Playgroud)

cocoa-touch objective-c storyboard uinavigationcontroller ios

6
推荐指数
1
解决办法
2740
查看次数

FlyoutNavigation - iOS

我正在尝试使用Clancey FlyoutNavigation,但是我无法让它执行一个segue.

我希望它像导航菜单一样工作,所以如果我按下"开始"它会转到我的故事板上的某个视图

这是我目前的代码,但它根本不起作用.

var navigation = new FlyoutNavigationController {
                // Create the navigation menu
                NavigationRoot = new RootElement ("Navigation") {
                    new Section ("Pages") {
                        new StringElement ("Start"),
                    }
                },
                // Supply view controllers corresponding to menu items:
                ViewControllers = new [] {
                    new UIViewController { this.PerformSegue("toError", this) },
                },
            };
            // Show the navigation view
            navigation.ToggleMenu ();
            View.AddSubview (navigation.View);
Run Code Online (Sandbox Code Playgroud)

c# uiviewcontroller uinavigationcontroller ios xamarin

6
推荐指数
1
解决办法
792
查看次数

Swift - 滚动缩小导航栏

我真的被困在这里了.当我向下滚动UITableView时我想缩小导航栏,并在向上滚动时再次放大它.我设法改变导航栏的大小,但标题图像没有缩小导航栏.

我想完全像Safari一样,问题是我的TitleView的高度正在缩小,但宽度永远不会改变.

这是我用来获取滚动条高度的代码.

func scrollViewDidScroll(scrollView: UIScrollView) {
    var navbar = navigationController?.navigationBar
    var dir:CGPoint = tableview.panGestureRecognizer.translationInView(self.tableview)
    var scrollViewHeight = tableview.frame.size.height
    var scrollContentSizeHeight = tableview.contentSize.height
    var scrollOffset = tableview.contentOffset.y

    if (dir.y > 0 && self.formernavstate == "small") {
        self.formernavstate = "big"

        UIView.animateWithDuration(0.5, delay:0.0, options: UIViewAnimationOptions.AllowAnimatedContent, animations: { () -> Void in

        println("")
        navbar?.frame.origin.y = 20
        self.navigationItem.titleView?.transform = CGAffineTransformMakeScale(0.52, 0.6)
        }, completion: nil)
    }

    if (dir.y < 0 && self.formernavstate == "big") {
        self.formernavstate = "small"   
        navbar?.frame.origin.y = 0
        navigationItem.titleView?.transform = CGAffineTransformMakeScale(0.0001, 0.2) …
Run Code Online (Sandbox Code Playgroud)

uinavigationcontroller uinavigationitem navbar ios swift

6
推荐指数
1
解决办法
4142
查看次数

隐藏导航栏 Swiftui

我在 SwiftUI 中的 NavigationView 遇到问题,我添加了此代码来隐藏导航并且工作正常,但是在滚动视图时出现粘性标题如何删除它?谢谢!!

NavigationView {
...
}
.navigationBarTitle("")
.navigationBarHidden(true)
.navigationBarBackButtonHidden(true)
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

uinavigationcontroller navigationview swiftui

6
推荐指数
1
解决办法
4913
查看次数

导航栏前面的 SwiftUI 视图

在我正在制作的 iOS 应用程序中,我使用 NavigationLink 从主视图转到另一个视图。我希望两个视图的导航栏中都存在一个按钮,该按钮将在视图中的所有内容之上叠加模糊效果。在主视图中,模糊效果很好,但在第二个视图中,导航栏和导航栏标题不会变得模糊,并保持在模糊视图的顶部。

如何使导航视图出现在第二个视图中的模糊下方?

主视图:

var body: some View {
    ZStack {
        NavigationView {
            ScrollView(.vertical) {
                . . .
            }
            .navigationBarItems(
            leading: Button(action: {
                    showBlurView.toggle()
                }) {
                    Text("Show blur view")
                }
            ),
            trailing: Button(action: {
                    NavigationLink(destination: SecondView()) {
                        Text("2nd view")
                    }
                }
            )
        }
        
        BlurEffectView(style: .systemThinMaterial)
            .edgesIgnoringSafeArea(.all)
            .hidden(showBlurView == true ? false : true)

    }
}
Run Code Online (Sandbox Code Playgroud)

第二个视图:

var body: some View {
    ZStack {
        VStack {
            ...
        }.navigationBarTitle("Second View")

    BlurEffectView(style: .systemThinMaterial)
            .edgesIgnoringSafeArea(.all)
            .hidden(showBlurView == true ? false : …
Run Code Online (Sandbox Code Playgroud)

uinavigationcontroller ios swift swiftui

6
推荐指数
0
解决办法
2061
查看次数

在 iOS 15 上从不透明导航栏导航到具有透明导航栏的视图控制器

在 iOS 15 上,当导航到具有透明导航栏的视图控制器时,透明栏的动画无法按预期工作。

但是,如果您导航回带有透明导航栏的视图控制器,动画将按预期工作。

这就是我设置视图控制器的方式:

根VC

let appearance = UINavigationBarAppearance()
appearance.configureWithDefaultBackground()
appearance.backgroundColor = UIColor.red

self.navigationController?.navigationBar.standardAppearance = appearance
self.navigationController?.navigationBar.scrollEdgeAppearance = self.navigationController?.navigationBar.standardAppearance
Run Code Online (Sandbox Code Playgroud)

第一VC

let appearance = UINavigationBarAppearance()
appearance.configureWithTransparentBackground()

self.navigationController?.navigationBar.standardAppearance = appearance
self.navigationController?.navigationBar.scrollEdgeAppearance = self.navigationController?.navigationBar.standardAppearance
Run Code Online (Sandbox Code Playgroud)

第二VC

let appearance = UINavigationBarAppearance()
appearance.configureWithDefaultBackground()
appearance.backgroundColor = UIColor.yellow

self.navigationController?.navigationBar.standardAppearance = appearance
self.navigationController?.navigationBar.scrollEdgeAppearance = self.navigationController?.navigationBar.standardAppearance
Run Code Online (Sandbox Code Playgroud)

请注意以下示例中从secondaryVC -> firstVC的过渡是多么平滑,但不是从rootVC -> firstVC的过渡:

视频演示

示例项目: https: //github.com/karlingen/NavigationTest

有什么想法为什么会这样吗?

uinavigationbar uinavigationcontroller ios uinavigationbarappearance ios15

6
推荐指数
1
解决办法
1122
查看次数