标签: uinavigationcontroller

UINavigationController和UITabBarController中的选择性自动旋转

问候!这是场景.

从导航控制器开始(并且没有标签栏 - 它在以前的视图控制器推送中隐藏),我启动一个新的视图控制器并将其推送到导航控制器堆栈.这个新的VC包含一个寂寞的UIView,我在其中以编程方式添加具有相同帧的UIScrollView.(我想避免使用UIView,但这是我可以将self.view分配给某些东西的唯一方法.我怀疑在viewDidLoad中将UIScrollView转换为UIView是不可取的.)

所以现在我们有一个导航栏和一个滚动视图.我把它设置为滚动浏览一些图像(大惊喜,我知道!),这很好用.现在我希望这支持自动旋转.所以我在VC中回答如下:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
Run Code Online (Sandbox Code Playgroud)

编译并运行.Aaaand ......没什么.显然我做错了什么.

现在,我已经阅读了有关UINavigationController和autorotation的帖子,我怀疑我正在以错误的方式解决这个问题,并且让它变得更加复杂.

必须有一种更好的方式来呈现支持自动旋转的UIScrollView.也许导航控制器正在阻碍,但我不知道如何解决它.

理想情况下,我喜欢没有任何导航条显示的东西.相反,我们有一个工具栏/状态栏,从顶部显示/隐藏(就像你在播放视频时看到的那样).如果导航栏必须保留 - 或者如果真的是一个较短高度的导航栏,我在播放视频与工具栏时会看到,但是我是否可以旋转?问题是,我只希望它在查看像素时以这种特定模式旋转.不是在任何其他时间.

我敢尝试使用模态VC吗?(Yeccch - 不,那也不对.加上它还有一个导航栏.)

iphone rotation uitabbarcontroller uiscrollview uinavigationcontroller

5
推荐指数
2
解决办法
9445
查看次数

重用UIViewController用于模态和非模态情况

我有一个UIViewController - 我们称之为"FormController" - 它只是一个编辑对象的表单.我想在两种不同的情况下使用它:

  1. 创建一个新对象 - 使用UINavigationController的presentModalViewController:方法.

  2. 编辑现有对象 - 将视图控制器推送到UINavigationController堆栈,而不是使用对话框方法.

在模态情况下,我希望有一个带有"取消"和"完成"按钮的工具栏,但在堆栈情况下,我想要只有UINavigationController提供的导航栏.

这类似于Contacts应用程序,其中"New Contact"和"Edit Contact"屏幕似乎使用相同的视图控制器,但New Contact表单以模态方式呈现,而Edit屏幕被推送到导航堆栈.

我的问题是:在不必编写2个独立但大部分相同的视图控制器的情况下,处理这两种情况的最佳方法是什么?

我想创建一个"ModalFormController",通过组合封装裸"FormController"并添加一个工具栏,但我在文档中的某处读到Apple不建议嵌套视图控制器.

iphone cocoa-touch uiviewcontroller uinavigationcontroller ios

5
推荐指数
1
解决办法
1979
查看次数

如何在UINavigationController的工具栏中添加进度条,如Mail应用程序?

我的应用程序连接到网络以检索一些数据,我想在我的应用程序的UINavigationController的工具栏中显示一个进度条.

我真正想要的是与Mail应用程序非常相似:

                                      Mail应用程序的屏幕截图,显示示例工具栏布局

除了我想在进度条的左边没有任何内容,右边有一个取消按钮.

我已经摆弄了代码,尝试这样做,但我以前从未使用过导航控制器的工具栏,所以我不确定从哪里开始.

有谁知道我可能会这样做,或者我可以找到资源解释如何做到这一点?

我已经阅读了人机界面指南,UINavigationController类参考和View Controller编程指南,但它们只展示了如何使用简单的按钮和分段控件来完成非常基本的工具栏布局.

iphone user-interface toolbar uinavigationcontroller

5
推荐指数
1
解决办法
3845
查看次数

当"以编程方式"创建UINavigationController和UITabBarController时,如何解决它们的功能(如viewWillAppear?)

我在启动时通过以下代码在代码中创建我的Nav和TabBar:IN:myAppDelegate.m

- (void)applicationDidFinishLaunching:(UIApplication *)application { 
    // set up a local nav controller which we will reuse for each view controller
    UINavigationController *localNavigationController;

    // create tab bar controller and array to hold the view controllers
    tabBarController = [[UITabBarController alloc] init];
    NSMutableArray *localControllersArray = [[NSMutableArray alloc] initWithCapacity:4];

    // setup the first view controller (Root view controller)
    RootViewController *myViewController;
    myViewController = [[RootViewController alloc] initWithTabBar];

    // create the nav controller and add the root view controller as its first view
    localNavigationController = [[UINavigationController alloc] …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uitabbarcontroller uinavigationcontroller

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

如何从Tab栏控制器访问View Controller?

我有一个标签栏控制器,每个标签都包含一个导航控制器.

如何在选项卡中访问导航控制器中的特定视图控制器,以便我可以访问特定于视图控制器的属性?

我尝试了以下代码:

//Get the navigation controller of the 3rd tab
self.tabController.selectedViewController 
= [self.tabController.viewControllers objectAtIndex:2];

//Attempt to retrieve the viewcontroller I want from the tabcontroller
SomeViewController *svc = (SomeViewController *)self.tabController.selectedViewController;

//Attempting to access a BOOLEAN property in svc viewcontroller
svc.someProperty = YES;
Run Code Online (Sandbox Code Playgroud)

上面的代码失败了,因为似乎"self.tabController.selectedViewController"返回了一个导航控制器.如何扩展代码以便我可以访问"svc.someProperty"?

objective-c uinavigationcontroller ios

5
推荐指数
1
解决办法
6329
查看次数

我应该使用相同的细节ViewController在模态和推送时工作吗?

这似乎是整个Apples应用程序中使用的模式; 通过模态视图创建新记录,需要保存或取消以继续,并且通过推入导航堆栈的视图来编辑记录.

基本上将我的ViewController复制为"添加"和"编辑"似乎并不正确,但推送和模态ViewControllers的工作方式有很多不同之处.

我应该怎么做才能覆盖两个基地?

-

差异包括.

当推入堆栈时,导航栏出现在视图的顶部,可以配置为包含取消/保存按钮.当以模态方式呈现时,情况并非如此,因此复制界面需要单独创建工具栏并关闭/保存添加到此的按钮.

当解除推送视图时,我们向导航控制器发送消息[self.navigationController popViewControllerAnimated:YES];,当解除模态视图时,我们向自己发送消息[self dismissModalViewControllerAnimated:YES];

objective-c uinavigationcontroller modalviewcontroller ios

5
推荐指数
1
解决办法
135
查看次数

弹出视图的自定义故事板Segue?

我有我的故事板一个UINavigationController设置和我做了一个自定义赛格瑞类,你可以看到下面这我的看法之间很好地淡化(而不是一个沼泽标准推).

然而,当我点击我的导航控制器给我的那个后退按钮时,我得到一个我不想要的推动画,我想要使用那个褪色!我也不想在我的故事板中有两个段落,因为它只是变得混乱.

任何帮助非常感谢!

自定义淡入淡出:

-(void)perform
{
    __block UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
    __block UIViewController *destinationController = (UIViewController*)[self destinationViewController];

    [UIView transitionWithView:sourceViewController.navigationController.view duration:1.0 options:UIViewAnimationOptionTransitionCrossDissolve
                    animations:^
                    {
                        [sourceViewController.navigationController pushViewController:destinationController animated:NO];
                    }
                    completion:^(BOOL finished)
                    {
                        NSLog(@"Transition Completed");
                    }];
}
Run Code Online (Sandbox Code Playgroud)

编辑:

也许我应该简化.如何在UINavigationController中的两个视图控制器之间进行交叉消除淡入淡出,该视图控制器推送和弹出视图而不是标准的左右侧面动画?

谢谢.

objective-c storyboard uinavigationcontroller ipad segue

5
推荐指数
1
解决办法
1627
查看次数

认为不适用于iOS6

如果我的问题听起来对你们有些愚蠢,请原谅.我对iOS开发相对较新,但我必须为iOS6移植应用程序.该应用程序在iOS 5和XCode 4.3.2上运行良好,但我在iPhone 6.0模拟器上有一个奇怪的Xcode 4.5错误.加载初始屏幕后,我可以点击我想要的任何按钮,我收到错误:

 `Terminating app due to uncaught exception 'NSGenericException', reason: 'Could not find a navigation controller for segue 'register'. Push segues can only be used when the source controller is managed by an instance of UINavigationController.`
Run Code Online (Sandbox Code Playgroud)

StartScreenViewController的prepareForSegue方法如下所示

if ([[segue identifier] isEqualToString:@"register"] || [[segue identifier] isEqualToString:@"forgotPassword"]) {
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:[segue destinationViewController]];
    appDelegate.window.rootViewController = navController;
}
Run Code Online (Sandbox Code Playgroud)

设置断点显示该方法仍然被称为corectly,但在prepareForSegue完成后,应用程序崩溃并出现上述错误.有人能指出我正确的方向吗?

非常感谢马丁

iphone uinavigationcontroller segue ios6

5
推荐指数
2
解决办法
7253
查看次数

尝试在使用OAuth演示者时显示UINavigationController

我正在整合Facebook登录Xamarin PCL.我已经按照示例"漫画书" https://github.com/moljac/Xamarin.Auth.Samples.NugetReferences并将登录过程集成到我的应用程序中.

但是,我从Xamarin PCL项目中调用oauth演示者以在iOS上的应用程序中显示Facebook UI时,我得到了以下异常.我提供了下面使用的代码来调用Facebook UI进行登录.

错误:警告:尝试在Xamarin_Forms_Platform_iOS_PlatformRenderer:0x7ffa00576b80上显示UINavigationController:0x7ffa01275a00,其视图不在窗口层次结构中!

码:

var auth = new OAuth2Authenticator(
                clientId: FacebookClientId,
                scope: "email", 
                authorizeUrl: new Uri(FacebookAuthorizeUrl),
                redirectUrl: new Uri(FacebookRedirectUri));
                auth.AllowCancel = true;
                auth.Completed += async (s, es) =>
                {
                    if (es.IsAuthenticated)
                    {
                        var request = new OAuth2Request(
                        "GET",
                        new Uri("https://graph.facebook.com/me?fields=email,name,picture,cover,birthday"),
                        null,
                        es.Account);
                        var fbResponse = await request.GetResponseAsync();
                        if (fbResponse != null)
                        {
                                              var fbUser = JsonValue.Parse(fbResponse.GetResponseText()); // Getting the error for System.Json double exception issue as well for OAuth v1.5.0.0 only in iOS. …
Run Code Online (Sandbox Code Playgroud)

warnings oauth uinavigationcontroller xamarin.ios xamarin.forms

5
推荐指数
1
解决办法
247
查看次数

UIViewController:extendedLayoutIncludesOpaqueBars和滚动视图偏移

我的应用程序的视图层次结构非常简单:a UINavigationController包含一个UITableViewController。导航控制器的导航栏是不透明的,这会导致导航转换期间表视图的某些奇怪的插入行为,如下所示:

导航插图问题

为了解决这个问题,我设置extendedLayoutIncludesOpaqueBars到true上UITableViewController。这样做可以正确地将视图扩展到导航栏下方,但会以contentOffset我不太了解的方式更改表视图的行为。将此属性设置为时,true表格视图的Y值contentOffset报告其偏移量应比导航栏当前高度高(即,滚动表格视图1pt,它报告其y偏移量为-63pts )。

这使我认为导航控制器contentInset像半透明条一样自动管理滚动视图的。但是我看不到任何证据表明滚动视图中已设置了内容插图scrollViewDidScroll()。即使在表视图控制器上将其automaticallyAdjustsScrollViewInsets设置为false,内容偏移也不正确,因此似乎与插图无关。

Apple的文档extendedLayoutIncludesOpaqueBars未提及对滚动视图的内容偏移量的行为有任何影响。contentInset不幸的是,更改表视图的不能解决此问题。

我尝试更改表视图控制器的edgesForExtendedLayout属性,以强制其扩展而不影响滚动视图,但是对于不透明的条形来说,此属性似乎无能为力。

是否存在一些隐藏的行为,extendedLayoutIncludesOpaqueBars从而使滚动视图的内容偏移增加了?还是这可能是一个错误?

uitableview uiviewcontroller uikit uinavigationcontroller ios

5
推荐指数
1
解决办法
1747
查看次数