Tag: uiviewcontroller

如何实例化一个导航和选项卡控制器从其他视图控制器是在继续(显示详细信息)?

我之前问过一个问题,它成功的工作得益于其中一个答案如何从另一个视图控制器实例化导航控制器? ,但我遇到了一个新的问题,即每当我点击一个button从显示细节赛格,它应该导航到一个导航栏的正常选项卡,但它什么都没做。 这是故事板 这是场景 1)用户点击firstViewController上的一个button,它将继续显示到第三个显示细节的ViewController 2)用户点击另一个button,然后应该使用下面的代码去第二个ViewController 这是代码 在ThirdViewController中 @IBAction func buttonTapped(sender: UIButton) { guard let tabBarController = tabBarController else { return } let navController = tabBarController.viewControllers![1] as! UINavigationController let secondViewController = navController.topViewController as! SecondViewController secondViewController.name = "My name is TDog" tabBarController.selectedIndex = 1 } 我做错了什么? 我还需要实例化吗?

应用程序终止后,使用NSNotification在UIViewController中处理UILocalNotification

我正在使用UILocalNotification ,我想通知我的控制器之一,即使应用程序已被终止,通知已收到。 在我的appDelegate中,我实现了这个function: -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { if ([application applicationState] == UIApplicationStateInactive) { [[NSNotificationCenter defaultCenter] postNotificationName:@"localNotificationReceived" object:notification.userInfo]; } } 在我的UIViewController我在viewDidLoad方法上实现了观察者 – (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didlocalNotificationReceived:) name:@"localNotificationReceived" object:nil]; } 它运行在后台运行的应用程序完美。 由于viewDidLoad方法已经被调用,Observer正在等待.. 问题是当我杀了应用程序。 然后,我的控制器的观察者不见了, didlocalNotificationReceived方法从不被调用。 我认为这是因为当我收到localNotification并再次运行应用程序。 didReceiveLocalNotification:方法在我的UIViewController的viewDidLoad之前调用。 然后在PostNotificationName之后创build观察者,然后观察者不收到任何东西。 我想知道是否有一些最佳实践或模式来处理这类问题。 我知道didFinishLaunchingWithOptions方法是在didlocalNotificationReceived之前didlocalNotificationReceived因此可能有些事情要做。 更新: 我也发现,当应用程序被终止。 一旦你点击通知,它打开应用程序,调用函数didFinishLaunchingWithOptions但从来没有调用didReceiveLocalNotification 。 所以我认为我会处理两种情况。

当用户点击视图控制器时,如何使SWRevealViewController菜单消失

我有视图控制器与embeddedSWRevealViewController我已经添加下面的代码来禁用任何交互,而使用菜单。 视图控制器embeddedtableview。 当用户点击视图控制器时,如何使菜单消失作为松弛的应用程序“当菜单正在使用,你点击聊天菜单消失” class Feed: UIViewController,SWRevealViewControllerDelegate { @IBOutlet weak var menuButton:UIBarButtonItem! @IBOutlet weak var menuButton:UIBarButtonItem! override func viewDidLoad() { super.viewDidLoad() if self.revealViewController() != nil { menuButton.target = self.revealViewController() menuButton.action = "revealToggle:" self.revealViewController().delegate = self self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer()) } fetchMessages() } func revealController(revealController: SWRevealViewController!, willMoveToPosition position: FrontViewPosition) { if position == FrontViewPosition.Left // if it not statisfy try […]

ios视图控制器继续在内存中放样

我是Objective C新手。我正在开发我的第一个应用程序。 – 它基本上由2个视图控制器组成,我使用模态segue在它们之间切换。 主vc是一个菜单,为每个菜单项加载不同的属性的第二个vc。 – 我注意到,当我从一个VC切换到另一个时,内存不断增加。 这是我试图解决这个问题,但它没有影响,它看起来不干净。 -(void)viewDidDisappear:(BOOL)animated{ ViewController *me = self; me = nil; } 在这种情况下处理内存的最佳做法是什么?

iOS:在当前的模式视图控制器后面切换视图控制器?

当我启动我的应用程序,我提出了根视图控制器(目前只是一个图片),然后popup一个模态视图控制器的步行通过。 一旦用户完成了漫步,我想解除模态视图控制器,并让用户立即呈现应用程序(而不是根)的主视图控制器。 我的问题是我不知道如何去做这件事。 目前我所能做的只是将模式退回到根,然后将根视图控制器切换到主视图控制器。 这使得一个非常丑陋的过渡。 //WalkthroughViewController.m -(void)completeWalkthrough:(UIButton *)sender { // What can I do here to switch the RootViewController // to display MainViewController ? [self dismissViewControllerAnimated:YES completion:nil]; } 任何帮助表示赞赏。 谢谢。

导航栏更改高度

当我把我的UIViewController从我以前的控制器中推到屏幕上时,它会改变这个变化。 但是,当它完成加载它的大小我的导航栏和跳跃转换使它看起来不好。 我怎样才能解决这个问题? 我所做的只是在viewWillAppear隐藏控制器A中的导航栏,并在viewDidLoad中的控制器B中显示它。

hidesBottomBarWhenPressed在返回ViewController时没有设置

我有我的UIViewController(称为ViewControllerA)被推入到我的UINavigationController堆栈之一的hidesBottomBarWhenPushed = true设置。 我也select在ViewControllerA的ontop上显示bottomBar。 所以我有: class ViewControllerA: UIViewController { override func viewWillDisappear(animated: Bool) { self.hidesBottomBarWhenPushed = false } override func viewWillAppear(animated: Bool) { self.hidesBottomBarWhenPushed = true } 这一切工作正常。 当我推ViewControllerA,底部栏隐藏。 当我推任何其他的ViewController,底部栏显示。 但是,当我在导航堆栈中向后行进(又名UIBarButtonItemBackbutton)时,popup导航堆栈以显示ViewControllerA时,无法隐藏bottomBar。 我错过了什么? 谢谢!

从UIPopover发送委托消息到主UIViewController

我试图在我的UIPopover使用button来创build一个UITextView在我的主要UIViewController代码我看起来像这样( PopoverView.h文件): @protocol PopoverDelegate <NSObject> – (void)buttonAPressed; @end @interface PopoverView : UIViewController <UITextViewDelegate> { //<UITextViewDelegate> id <PopoverDelegate> delegate; BOOL sendDelegateMessages; } @property (nonatomic, retain) id delegate; @property (nonatomic) BOOL sendDelegateMessages; @end 然后在我的PopoverView.m文件中: – (void)viewDidLoad { [super viewDidLoad]; UIButton * addTB1 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; addTB1.frame = CGRectMake(0, 0, 100, 50); [addTB1 setTitle:@"Textbox One" forState:UIControlStateNormal]; [self.view addSubview:addTB1]; […]

如何重新加载UIVIew的UIViewController数据

实际上我有一个UIVIewController它有一个自定义类的UIViewcontroller在UIViewcontroller我有一个标签,我需要打印UIView定义的标签的值。 但是UIViewController viewdidload是先编译的,然后编译器移动到UIView ,然后我怎么打印或重新载入UIVIewController 。 UILabel Text我在UIViewController的View DidLoad中定义了从UIView类中取得的值 那么如何重新加载UIViewController 。 我正在做的是: UIVIewController (thirdTab)类 -(void)viewDidLoad{ [self reloadInputViews1]; } -(void)reloadInputViews1{ appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; // labelPrint.text=appDelegate.dayPrint; [self.labelPrint setText:labelPrint.text]; } UIView类 – (void)drawRect:(CGRect)rect { AppDelegate* appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; appDelegate.dayPrint=theDate; NSLog(@"appde%@",appDelegate.dayPrint); [appDelegate.thirdTab reloadInputViews1]; } 但是这不起作用…我不能够在label.how中打印值..要从UIViews中获取值

随着3D触摸偷看和stream行,你如何检测用户平移过程中(如Facebook)?

在Facebook应用程序中,如果您“窥视”作为相册一部分的照片,则可以水平滑动手指以转到其他照片。 这在API中如何完成? 我所看到的全部是提供一个视图控制器,并提交popup视图控制器。