Tag: uinavigationcontroller

以无编程方式实例化UIViewController

我想创build一个UIViewController程序化,而不使用笔尖或故事板。 我认为这足以实现UIViewController为: class TestViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() //Add some setup code here, without it it should just be blank } } 使用let vc = TestViewController(nibName: nil, bundle: nil)或者只是TestViewController() 然后只是推它: navigationController?.pushViewController(vc, animated: true) 但它显示了一个透明的navigationController (上方的酒吧)(后面的UIWindow显示,我有一个多窗口设置)

在自定义的UINavigationBar中绘制,附在顶部

我有一个UINavigationBar的子类。 它的barPosition是UIBarPositionTopAttached 。 比我重写-(void)drawRect:(CGRect)rect在我的子类。 作为参数的rect总是有44像素的高度,而且我只能在这个矩形内部绘制。 所以,我不能执行绘图状态栏,它有默认的外观。 如果我评论 – -drawRect ,看起来如预期,导航栏和状态栏看起来整体,并有64像素的高度。 有没有一种方法来实现这个效果与-drawRect:在UINavigationBar子类?

从UIView ios推视图控制器

我有一个基于导航的应用程序。在第一个屏幕上点击导航栏上的一个button,我可以按如下方式推送另一个视图控制器: -(void) buttonClicked:(id)sender { UIViewController* mv = [[SecondViewController alloc] init]; [[self navigationController] pushViewController:mv animated:YES]; } 现在我有一个UIView(单独的.h和.m文件)作为第一个屏幕的一部分。 点击UIView中的一个button,我想推动SecondViewController。 我已经尝试了以下内容: UIViewController* mv = [[SecondViewController alloc] init]; UIViewController * home=[[FirstViewController alloc]init]; [[home navigationController] pushViewController:mv animated:YES]; 它不工作! 请帮助

无法停止设备旋转

我在这里发布了一个问题。 其中一个好友回答并给出了解决办法。 虽然这个解决scheme在很less的视图控制器上工作,但是看起来不行。 当我进入一个视图控制器的TabController +导航控制器的那里标签栏项目,代码不起作用。 和意见是能够旋转。 我使用iOS 6.1的以下代码 //For iOS6 – (BOOL)shouldAutorotate { return NO; } – (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationPortrait; } – (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } 我也必须在iOS 7中实现同样的东西。 请帮忙

如何使iPad上的模式视图上的翻转animation在后台透明?

如何使我的翻转animation透明,以便它后面的视图显示? 这是我的一些代码: EditInfoViewController *editController = [[EditInfoViewController alloc] initWithNibName:@"EditInfoViewController" bundle:nil]; editController.delegate = self; UINavigationController *editNavController = [[UINavigationController alloc] initWithRootViewController:editController]; editNavController.modalPresentationStyle = UIModalPresentationCurrentContext; editNavController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self.navigationController presentModalViewController:editNavController animated:YES]; 一张照片值1000字(这是在翻页animation中拍摄的):

iOS – 收到推送通知后显示视图

我正在开发一个应用程序,其主UI基于标签栏控制器。 在其中一个选项卡中,我有一个集合视图,通过导航控制器深入到详细视图。 我想要做的是在接收到推送通知时,我想select这个特定的选项卡,从服务器获取最新的数据,find要显示的特定项目,然后将详细视图推到屏幕上以显示所述项目。 我的问题是,我收到以下消息之后collectionView:didSelectItemAtIndexPath: 终止由于未捕获exception“NSGenericException”的应用程序,原因:'无法find一个导航控制器for segue'FavouriteItem'。 只有当源控制器由UINavigationController的一个实例pipe理时,才能使用push segues。 以下是我到目前为止所做的: 应用程序委托应用程序:didReceiveRemoteNotification: [self selectFavouritesTab]; NHFavouritesViewController *favouritesViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"Favourites"]; [favouritesViewController displayFavouriteForPushNotificationWithId:favouriteId]; 从FavouritesViewController – 获取最新的collections夹后,我发送一条消息displayFavouriteItemWithId: – (void)displayFavouriteItemWithFavouriteId:(NSNumber*)favouriteId { NSArray* results = [_collectionViewData filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF.favouriteId == %@", favouriteId]]; NSInteger row = [_collectionViewData indexOfObject:[results lastObject]]; NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:0]; [[self collectionView] selectItemAtIndexPath:indexPath animated:YES scrollPosition:UICollectionViewScrollPositionNone]; [self.collectionView.delegate collectionView:self.collectionView […]

如何将多个视图控制器推送到导航控制器上

新手在这里编程我的第一个应用程序(做了几个教程应用程序)。 我正在使用称为“RootViewController”的视图控制器作为导航控制器。 我已经使用以下命令成功地将另一个视图控制器放在了名为“ClientListViewController”的顶部: [self.navigationController pushViewController:clientListViewController animated:YES]; 我现在在ClientListViewController,并试图推动另一个视图控制器到名为“AddClientViewController”的堆栈。 我想以UIModalPresentationFormSheet的forms使这个模态视图控制器。 我试图使用上面的命令的变种推新视图控制器,但我不知道如何取代“自我”。 我努力了: [RootViewController.navigationController pushViewController:AddClientViewController animated:YES]; 和… [[RootViewController navigationController] pushViewController:AddClientViewController animated:YES]; 以及这些组合中的每一个都使用小的“R”来表示Root。 仍然没有运气。 为了清楚起见,我在我的实现文件的顶部使用了下面的代码。 #import "AddClientViewController.h" 我是以正确的方式处理这个问题,还是应该使用全新的导航控制器将其添加到? 任何指针大大收到。 非常感谢

推导UIViewController没有导航控制器

我正在使用该方法推入另一个UIViewController在条件: initViewController *MW = [initViewController alloc]; MW = [self.storyboard instantiateViewControllerWithIdentifier:@"init"]; [self.navigationController pushViewController:MW animated:YES]; 现在我已经改变了我的架构,我刚刚删除了我的导航控制器。 这就是为什么,这些步骤不会再帮助我,因为没有NavigationController存在。 现在我怎么能不按下button – (IBAction)推另一个ViewController。 我只是想在故事板中使用它。 问候。

导航栏和表格视图之间的黑条出现在iOS 6上

自从我开始使用iOS 6之后,我似乎遇到了一个问题,在使用iOS 5时没有出现这个问题。起初,我认为这可能只是一个模拟器错误,但是从今天在iPhone 5上testing之后,我可以看到它不只是在模拟器中。 我以编程方式创build所有东西 – 我似乎更喜欢这样做(我认为这是因为我的HTML / CSS背景!) – 但是我还是比较新的Objective-C,我找不到完整的示例如何以编程方式设置导航控制器/表视图,所以我把它从我能find的信息的金块放在一起,因此,我可能会做一些根本性的错误。 但是,它在iOS 5上工作(并仍然有效)。 问题是我在导航栏和表格视图之间有一个黑条,但奇怪的是,如果我推视图并返回到原始视图,栏会消失,直到我完全重新启动才会重新出现该应用程序。 下面的图片是在启动(1)时的应用程序,我正在推动(2)中的一个视图,以及在我回到它之后的初始视图(3): 这就是我的代码: AppDelegate.m – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; RootViewController *rootController = [[RootViewController alloc] init]; self.window.rootViewController = rootController; self.navigationController = [[UINavigationController alloc] initWithRootViewController:rootController]; [self.window addSubview:navigationController.view]; [self.window makeKeyAndVisible]; NSLog(@"Window frame: %@", NSStringFromCGRect(self.window.frame)); return YES; } […]

setNavigationBarHidden与animation不工作在iPad上

当用户点击一个button时,我在我的应用程序中使用下面的代码: [self.navigationController setNavigationBarHidden:NO animated:YES]; 外观通常在iPhone上animation,而不是在iPad上。 你知道为什么吗 ?