get viewControlelr appear event - ios

When I touched the indication input, and click learn more, this will show from current viewController, however, when i touched the button "完成" which means done, the viewconteoller never go to the method as viewWillAppear or viewDidAppear, my viewController is landscape and this is potrait,so this cause the problem, I need go get the event when this page dismissed to fix the direction, anyone had good ideas to resolve this? Thanks

I resoled it with print all notifications, UIWindowDidBecomeKeyNotification can resolve my problem as this system page will use a new window to be keywindow, when it dismissed, the window of my viewController will be keywindow, i can use this to resolve my problem

Related

Force Touch animation freezes if gently touched

I have implemented Force Touch in my app in the chat view. When a user force-touches the chat message bubble of the other user, his/her profile is presented. For some strange reason, when the message bubble is gently pressed, the interactive transition gets stuck and all that is visible is a screenshot of the view that is supposed to be phased out.
I've debugged this issue as well using the View Hierarchy Debugger and the UITransitionView is definitely the top-most view. The app does not crash - it is still running and the user can still receive messages but not view them, exit out of the screen, etc. because of the screenshot stuck on top.
Has anyone ever had any issues like this? Sounds like an Apple bug.
I found a reason for this bug.
If your view controller need to support preview for force touch, you need register this view controller with delegate by calling
- (id <UIViewControllerPreviewing>)registerForPreviewingWithDelegate:(id<UIViewControllerPreviewingDelegate>)delegate
sourceView:(UIView *)sourceView NS_AVAILABLE_IOS(9_0);
method to do this.
I just suddenly call this function twice (once in super class' viewDidLoad(), once in subview controller's), and when I remove once in my subview controller, this bug is fixed! Amazing...
It's still an Apple bug since it makes no sence for that happens. However, wish this answer can help developers who has the same issue with me.
FYI. I just browse your Github code, found no double calls for register method. Maybe there's other reason for this bug. You could try to remove register method in your UITableViewController's subclass. By the way, I reproduce this issue when a view controller use ComponentKit.

Is there anyway I can find out the viewcontroller being shown on the screen in the app without using viewWillAppear/viewWillDisappear

I am trying to find the page the user is viewing at a given point of time. Is this possible without making any call from viewWillAppear or viewDidLoad. I have tried keywindow but it works only for navigation controller and it doesnt work as expected for tabBarController or a containerView.
Thank you.

'Minimize' a ViewController that user can access at any time anywhere in the app

I need some hints or suggestions on an issue.
What I want to do is to 'Minimize' a UIViewController like the 'message circles' in old facebook messages. So that the user can continue using the app and just move the circle to anywhere on the screen and then tap it to open it up and continue working from there.
The minimized UIViewController is suppose to be a UIWebView and I want the user to be able to continue working from whatever state the webpage was in.
I know one is suppose to add code here but I more want some pointers on where to start and how to think or possibly some suggested codesnippets or links.
Hope someone can help me out.
Thanks
edit: Thanks Moti. Ok so I will Not be using storyboard but do do everything programmatically.
I will have it not fully hidden but 'minimized' as an ontop circle to be accessed to just by tapping it anywhere from in the app.
Trick14, I will have a check. tnx
Make a Base View Controller which is inherited by every ViewController in your app. Declare the functions in it. And you can directly access these functions in any of your base class. Or simply hide or show your view anywhere in your app.
If its part of navigation controller you can keep strong reference to it somewhere, so when you pop it out it will stay alive. And when you need it you can push it again.
If you can describe some more details regarding how you show/hide and if its part of storyboard or built in runtime, the community will be able to be more specific regarding solutions.
If you look into UIViewController you will see
addChildViewController:
removeFromParentViewController
willMoveToParentViewController:
didMoveToParentViewController:
You can play around with those to achieve what you need, for example when you detect that the "overlay" controller removed from parent view controller you could push it back in the method didMoveToParentViewController: of the the other controller.
Yes, there is some management to be done, but it is possible.
I will try to make some working example with dummy views.

Does the method popViewControllerAnimated: act different than the Back button of the NavigationController?

In my Application i have a container ViewController which is the RootView of an UINavigationController.
I transit between various Child ViewControllers through a segmentedControl in the Toolbar of the UINavigationController.
One of the Child views pushes another View on the NavigationController, keeping the ToolbarItems.
Using the Back Button I get the desired behaviour of returning to the RootViewController, but any try of going back programatically won't change the view.
popViewControllerAnimated always takes the topViewController of the Stack but nether updates the View. viewWillAppear of the Container ViewController won't be called this way.
So i am wondering if the Back button does any additional Stuff which won't happen in with popViewControllerAnimated.
Also popViewControllerAnimated:YES will freeze the app without throwing an error.
Thanks for the help in advance.
Edit:
Ok one test case was a little of.
A popViewControllerAnimated in the topViewController of the Stack works as normal. But a call to popViewControllerAnimated through the SegmentedControll does not.
I realise the way i wrote this might be a little confusing, i will try to make this all a little clearer later.
Ok, it was a timing issue. I changed the ChildViews of the container ViewController directly after the call to popViewControllerAnimated.

ViewController loses its properties when I go back

I have two ViewControllers. The first has UITableview that I push data from to the second ViewController. Whenever I go back, the first ViewController loses its properties - Its navigationbar background disappears and for example the sidebar menu does not work either. Is there any way I could reload it while pushing the back button?
Thank you
Sounds like you are probably doing your setup in viewWillAppear instead of viewWillLoad. This means that when the view will appear on return, the setup is happening again and perhaps leaving you in an unexpected state. Put breakpoints in your view controller delegate methods and see what order things are being called in and why.

Resources