标签: uinavigationcontroller

UITableView pushViewController选择一行

我正在用UITableView构建一个iPhone应用程序.在选择一行时,我希望在加载特定URL时推送UIWebView.

我目前有:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath  {
NSDictionary * story = [stories objectAtIndex:[indexPath row]]; 
NSString * storyLink = [NSString stringWithFormat:[story objectForKey:@"link"]];

    [[self navigationController] pushViewController:[[FirstViewController alloc] initWithNibName:@"FirstView" bundle:[NSBundle mainBundle]] animated:YES];
}
Run Code Online (Sandbox Code Playgroud)

如何通过以下方式获取滑入的新视图以包含UIWebView并随后将故事链接加载到其中:

loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:storyLink]]
Run Code Online (Sandbox Code Playgroud)

提前致谢,

石磊

iphone cocoa-touch objective-c uitableview uinavigationcontroller

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

UINavigationBar不会在横向上更新"返回"

我正在开发一个UINavigationController驱动的iPad应用程序(在模拟器中测试).导航控制器堆栈上只有两个UIViewControllers.为了演示,我们称之为SetupController和ContentController.SetupController用栈推送ContentController

[self.navigationController pushViewController:contentController animated:YES];
Run Code Online (Sandbox Code Playgroud)

在查看内容时,您可以按后退按钮返回设置控制器.如果应用程序处于纵向模式,则一切正常.

然而,当应用程序处于横向状态并且我点击后退按钮时,事情就会变得混乱.视图控制器堆栈已正确更新(例如,我看到SetupController的视图),但UINavigationBar未正确更新.仍会显示与ContentController关联的UINavigation栏项.要查看SetupCotroller预期的UINavigationBar项目,我必须再次按下后退按钮,此时UINavigationBar会动画到正确的状态.同样,这只发生在横向模式,肖像模式完美.

作为测试.在[SetupController viewDidAppear:]方法中,我添加了以下调试输出

 if(self.navigationController.navigationBar.topItem != self.navigationItem) {
  NSLog(@"wrong nav item!");
 } else {
  NSLog(@"correct nav item!");
 }
Run Code Online (Sandbox Code Playgroud)

每当模拟器处于横向模式时,我都会收到"错误"的消息,而在纵向模式下则不会.我已经尝试删除所有viewDidAppear:来自ViewControllers和我正在修改其导航项或导航栏本身的任何实例的消息.

有什么想法吗?我假设我在这里做错了什么,但这对我来说肯定是个错误.

iphone objective-c uinavigationcontroller ipad

4
推荐指数
1
解决办法
1085
查看次数

自定义UINavigationController UINavigationBar

基本上我想要一个自定义UINavigationBar.我不希望它是"半透明的"或任何东西,如图片应用程序.

我基本上想要完全删除它,但我仍然希望能够添加按钮,例如当按下导航控制器时,我希望将视图(EG :) UITableViewController推到它下面.

像这样:

替代文字

任何想法如何实现这一点?

谢谢

iphone uinavigationbar uinavigationcontroller

4
推荐指数
2
解决办法
8509
查看次数

如何使UINavigationController的导航栏显示在底部?

有没有办法让UINavigationController显示器的默认导航栏位于底部而不是顶部?我知道有一个UIToolbar可以显示在底部,但是那个是特定于每个视图而不带"后退"按钮.

navigation iphone uinavigationcontroller navigationbar ios

4
推荐指数
1
解决办法
6101
查看次数

在UINavigationController中推送另一个View?

如何使用导航控制器中的按钮推送视图?我试着效仿这个例子:http: //www.cimgf.com/2009/06/25/uitabbarcontroller-with-uinavigationcontroller-using-interface-builder/

这正是我需要的,我有一个UITabBarController4个标签,其中一个是UINavigationController.我想从第一个视图推送包含导航控制器的视图 - 这很简单UIView.它不起作用,我尝试使用以编程方式创建的按钮,没有任何反应.有什么指针吗?

这是我的代码

@interface HomeViewController : UIViewController {

}

-(IBAction)pushViewController:(id)sender;

@end

---

#import "HomeViewController.h"
#import "NewViewController.h"

@implementation HomeViewController

-(IBAction)pushViewController:(id)sender {
        NewViewController *controller = [[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil];
    [[self navigationController] pushViewController:controller animated:YES];
    [controller release], controller = nil;
}
Run Code Online (Sandbox Code Playgroud)

这里也是连接的屏幕截图 http://imageshack.us/photo/my-images/847/screenshot20110719at620.png/

我已经尝试过你们建议但仍然没有,按钮(无论是创建Interface Builder还是编程)都表现得像是没有链接到任何方法.

iphone xcode uitabbarcontroller uinavigationcontroller

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

IOS ViewController导航路径 - 如何以编程方式导航

我正在使用IOS5 Storyboard.我的视图控制器路径如下:

tabbarVC --> navigationVC-1 --> tableVC-1 --(via segue push)-> tableVC-2 --(via segue modal)-> navigationVC-2 --> tableVC-3
Run Code Online (Sandbox Code Playgroud)

在表VC-3中的取消按钮回调动作方法中,我调用[self dismissViewControllerAnimated:YES completion:nil]; 成功让我回到tableVC-2.但是,当我尝试在调试器中向后检查导航路径时,我没有看到从navigationVC-2访问tableVC-2的方法.我期望navigationVC-2保持到tableVC-2或navigationVC-1的链接,但似乎没有.请参阅下面的调试器输出.

有人可以解释导航层次结构以及如何以编程方式向后遍历链接?

(gdb) po self
<tableVC-3: 0x6d33340>

(gdb) po (UIViewController*) [self navigationController]
<UINavigationController: 0x6d33560>

(gdb) po (UIViewController*)[[self navigationController] navigationController]
Can't print the description of a NIL object.

(gdb) po (UIViewController*)[[self navigationController] topViewController]
<tableVC-3: 0x6d33340>

(gdb) po (UIViewController*)[[self navigationController] presentingViewController]
<UITabBarController: 0x6b2eba0>

(gdb) po (UIViewController*)[[self navigationController] presentedViewController]
Can't print the description of a NIL object.

(gdb) po (UIViewController*)[[self navigationController] visibleViewController] …
Run Code Online (Sandbox Code Playgroud)

uinavigationcontroller ios ios5 xcode-storyboard

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

使用UIBarButtonItem将UISearchBar添加到UINavigationBar

在我的应用中,我以前在表格视图的标题视图中有一个搜索栏。但是,我添加了一个搜索栏按钮项,并且当用户点击它时,我希望搜索栏在整个导航栏中设置动画,并且用户应该能够搜索。这有点像Twitter iOS应用中的搜索栏。这是我的UISearchController的代码:

self.searchController = ({
        let controller = UISearchController(searchResultsController: nil)
        controller.searchResultsUpdater = self
        controller.hidesNavigationBarDuringPresentation = true
        controller.dimsBackgroundDuringPresentation = false
        controller.searchBar.sizeToFit()
        //self.tableView.tableHeaderView = controller.searchBar
        self.definesPresentationContext = true
        controller.searchBar.returnKeyType = .Search
        controller.searchBar.delegate = self

        return controller

    })()
Run Code Online (Sandbox Code Playgroud)

这是我的UINavigationBar现在的样子: 在此处输入图片说明

我将如何去做呢?

uinavigationbar uinavigationcontroller uisearchbar ios swift

4
推荐指数
1
解决办法
7290
查看次数

swift ios无法更改导航栏标题

我有一个模态VC,我使用故事板在导航栏中拖动:

在此输入图像描述

但现在我只能在故事板中而不是在代码中更改标题.我需要能够在代码中更改它,因为标题将是动态的.

我试过这两个:

self.title = "some title"

navigationBar.topItem.title = "some title"
Run Code Online (Sandbox Code Playgroud)

但它们都不起作用,我也没有得到任何警告/错误

xcode uinavigationcontroller uinavigationitem ios swift

4
推荐指数
1
解决办法
2134
查看次数

按下导航后退按钮时如何调用功能?

当我按下后退按钮时,我需要调用一个函数.优选地,不必创建另一个按钮

uinavigationcontroller ios swift

4
推荐指数
2
解决办法
1353
查看次数

如何比较Swift 3中的UIViewController?

我想在Swift 3中与UIViewController进行比较,但是有一些错误

extension UINavigationController
{
    func myPopToViewController(viewController:UIViewController, animated:Bool) -> UIViewController? {
        var arrViewControllers:[UIViewController] = []

        arrViewControllers = self.viewControllers
        for vc:UIViewController in arrViewControllers {
            if(vc.isKind(of: viewController) ) // This Line gives me error
            {
                return (self.navigationController?.popToViewController(vc, animated: animated)?.last)!
            }

        }
        return nil
    }

}
Run Code Online (Sandbox Code Playgroud)

/Users/varunnaharia/Documents/Projects/appname/appname/Public/UINavigationController+Extra.swift:18:30:无法将'UIViewController'类型的值转换为预期的参数类型'AnyClass'(又名'AnyObject.Type')

如果尝试使用

if(vc is viewController)
Run Code Online (Sandbox Code Playgroud)

它给

/Users/varunnaharia/Documents/Projects/appname/appname/Public/UINavigationController+Extra.swift:18:22:使用未声明的类型'viewController'

我通过这个称呼它

self.navigationController?.popOrPopToViewController(viewController: MyUIViewController(), animated: false)
Run Code Online (Sandbox Code Playgroud)

uiviewcontroller uinavigationcontroller ios swift swift3

4
推荐指数
4
解决办法
7662
查看次数