天道酬勤,学无止境

uiviewcontroller

如何使模态视图控制器透明(how to make the modal view controller transparent)

问题 我正在使用当前视图控制器从左侧显示一个新的视图控制器..我使用的代码是.. UIViewController *controller; UINavigationController *navi; UIView *popmenu = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 300)]; popmenu.backgroundColor = [UIColor yellowColor]; controller.view = popmenu; controller.view.superview.backgroundColor = [UIColor clearColor]; navi = [[UINavigationController alloc]initWithRootViewController:controller]; navi.view.superview.backgroundColor = [UIColor clearColor]; CATransition *transition = [CATransition animation]; transition.duration = 0.4; transition.timingFunction = [CAMediaTimingFunction

2021-09-24 06:31:03    分类:技术分享    ios   objective-c   uiviewcontroller

如何使模态视图控制器透明(how to make the modal view controller transparent)

问题 我正在使用当前视图控制器从左侧显示一个新的视图控制器..我使用的代码是.. UIViewController *controller; UINavigationController *navi; UIView *popmenu = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 300)]; popmenu.backgroundColor = [UIColor yellowColor]; controller.view = popmenu; controller.view.superview.backgroundColor = [UIColor clearColor]; navi = [[UINavigationController alloc]initWithRootViewController:controller]; navi.view.superview.backgroundColor = [UIColor clearColor]; CATransition *transition = [CATransition animation]; transition.duration = 0.4; transition.timingFunction = [CAMediaTimingFunction

2021-09-24 06:29:28    分类:技术分享    ios   objective-c   uiviewcontroller

how to make the modal view controller transparent

I am using present view controller for displaying a new view controller from left.. the code i used is.. UIViewController *controller; UINavigationController *navi; UIView *popmenu = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 300)]; popmenu.backgroundColor = [UIColor yellowColor]; controller.view = popmenu; controller.view.superview.backgroundColor = [UIColor clearColor]; navi = [[UINavigationController alloc]initWithRootViewController:controller]; navi.view.superview.backgroundColor = [UIColor clearColor]; CATransition *transition = [CATransition animation]; transition.duration = 0.4

2021-09-24 00:33:03    分类:问答    ios   objective-c   uiviewcontroller

iOS Swift popToViewController 按名称(iOS Swift popToViewController by Name)

问题 我正在尝试弹出一个视图控制器,我认为它位于索引 0。我的 ViewController 名称是 HomeVC。 self.navigationController!.popToViewController(self.navigationController!.viewControllers[0] as! UIViewController, animated: true) 然而,上面的代码只会让我回到最近的视图控制器。 不知道为什么它不会进入我的 HomeVC 视图控制器。 他们是我可以使用 ViewController Name 弹出的一种方式吗? 回答1 Try this: for (var i = 0; i < self.navigationController?.viewControllers.count; i++) { if(self.navigationController?.viewControllers[i].isKindOfClass(YourDesiredViewController) == true) { self.navigationController?.popToViewController(self.navigationController!.viewControllers[i] as! DestinationViewController

2021-09-23 23:35:09    分类:技术分享    ios   swift   uiviewcontroller

呈现模式时“不鼓励在分离的视图控制器上呈现视图控制器”消息(“Presenting view controllers on detached view controllers is discouraged” message when presenting modal)

问题 我有一个导航控制器和根视图。 然后在那个根视图中,我在那里推送了一个视图,我必须单击才能观看内容,如果已登录,如果未登录,它将使用以下代码打开一个模态视图控制器。 var vc = self.storyboard?.instantiateViewControllerWithIdentifier("LoginViewController") as! LoginViewController self.tabBarController!.presentViewController(vc, animated: true, completion: nil) 在 viewdidload() 我有一个 nsnotification 以便当用户从登录模式登录时我可以得到通知 NSNotificationCenter.defaultCenter().addObserver(self, selector: ("didDismissSecondViewController:"), name: "SecondViewControllerDismissed", object: nil) 在完成所有工作后,在登录控制器中,我编写了以下代码 self.dismissViewControllerAnimated(true, completion: {NSNotificationCenter

2021-09-23 23:28:06    分类:技术分享    ios   swift   model-view-controller   uiviewcontroller   uistoryboard

Adding custom UIViewController with UITableView as a subview

I'm trying to create custom UIViewController with a UITableView, load the UIViewController using a xib file and add the view as a subview to another UIView. The hierarchy is like this: UIViewController UIView << add custom UIViewController's view UIView UIView Here's my xib view hierarchy and settings: UIView UITableView Connection in IB: File's Owner:CustomTableViewController Outlets: view connected to UIView tableView connected to File's Owner delegate connected to File's Owner datasource connected to File's Owner I have both UITableDataSource and UITableDelegate implemented. When i tried to

2021-09-23 19:16:31    分类:问答    objective-c   ios   uitableview   uiviewcontroller

is it good practice to share the ADD and EDIT screen to use the same UIViewController?

is it good practice to share the ADD and EDIT screen to use the same UIViewController? That is in the case where the only real difference would be in one the values would be populated with existing (EDIT). PS. Some clarification. So perhaps take the simple case where there is just one or two NSString fields (e.g. title & description) - so is there anything wrong (e.g any gottchas) associated with using the same controller/NIB(view) for both EDIT and ADD?

2021-09-23 18:19:16    分类:问答    iphone   ios   uiviewcontroller

如何关闭模态转场然后执行推送转场到新的视图控制器(How can I dismiss a modal segue then perform push segue to new view controller)

问题 在关闭之前通过navigation controller呈现的modal后,我正在尝试从navigation controller执行push segue 。 模态内部( UIViewController ): func textFieldShouldReturn(textField: UITextField) -> Bool { var searchNav = SearchNavigationController() self.dismissViewControllerAnimated(true, completion: {searchNav.goToNextView()}) return true } 在SearchNavigationController内部: func goToNextView() { performSegueWithIdentifier("searchNavigationToNextView", sender: self) } 问题是当我点击返回时,我收到此错误: 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“Receiver () 没有标识符为“searchNavigationToNextView”的segue segue 出现在我的storyboard

2021-09-23 16:47:52    分类:技术分享    ios   swift   uiviewcontroller   uinavigationcontroller   segue

弹出窗口中的 UIToolbar(UIToolbar in a popover)

问题 是否可以在弹出窗口内的 UIViewController 中显示工具栏项目? 我在我的视图控制器的 viewDidLoad 方法中这样做: UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:nil action:nil]; [self setToolbarItems:[NSArray arrayWithObject:addButton]]; [addButton release]; 然后我将这个视图控制器包装在UINavigationController (它有一个toolbar属性,根据文档,我应该使用UIViewController的setToolbarItems方法将项目添加到工具栏),然后在弹出窗口中显示它。 我没有看到工具栏。 使用弹出框时是否不支持工具栏? 谢谢 回答1 想通了,显然工具栏默认是隐藏的,所以你必须这样做: [self.navigationController setToolbarHidden:NO animated:NO]; 让它出现。

2021-09-23 16:10:32    分类:技术分享    cocoa-touch   ipad   uiviewcontroller   uinavigationcontroller   uitoolbar

如何在自定义 UIPresentationController 中使用 modalPresentationCapturesStatusBarAppearance = NO?(How to use modalPresentationCapturesStatusBarAppearance = NO with a custom UIPresentationController?)

问题 我有一个自定义 UIPresentationController 并覆盖 frameOfPresentedViewInContainerView 以获取自定义 viewController 演示文稿。 一切正常,除了状态栏。 我根本不希望状态栏改变外观——它应该保持原样。 现在苹果文档:https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/#//apple_ref/occ/instp/UIViewController/modalPresentationCapturesStatusBarAppearance 说如果 modalPresentationStyle 不是 UIModalPresentationFullScreen 或 modalPresentationCapturesStatus,我应该没问题,状态栏不应该改变。 使用此代码: - (BOOL)prefersStatusBarHidden { NSLog( @"prefersStatusBarHidden was called %d %ld", self.modalPresentationCapturesStatusBarAppearance, (long)self

2021-09-23 14:35:36    分类:技术分享    ios   uiviewcontroller   uistatusbar   uimodalpresentationstyle   uipresentationcontroller