Working in an app with Objective-C I got the next problem:
I have a code that executes an animation in a UIViewController that is called with input from the user and also when a push notification comes from other user using this app.
The matter is that the first time i enter this UIViewController it works fine, but when unwind-segue and segue again to this UIViewController the animation that is executed with the notification code stops working. The code is being executed but the animation isn't showing. The segues are working modally.
If you need to see some code please tell me.
Thanks T_77 i found the solution to this problem.
It seems like i have some timers that wasn't being invalidated. Invalidating them at ViewWillDessapear did the fix.
Related
I have a UITableView with various posts, that the user can comment on. Once the user taps on the comment button in the cell, the comments view controller is loaded, and viewwillappear is called but before presenting the view, the app freezes. I am making an API call to fetch the comments in viewDidLoad and reloading the table once the API call is finished. I am not able to figure where iOS 11 is doing things differently. Any help will be much appreciated.
Call API in background thread
let dispatchTime: DispatchTime = DispatchTime.now() + Double(Int64(0.1 * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
DispatchQueue.main.asyncAfter(deadline: dispatchTime, execute: {
DispatchQueue.main.async{
//Call API function here
}
})
The issue seemed to be with the Navigation Controller, like most issues on iOS 11 transition.
I was setting the right bar buttons for the viewcontroller in viewDidLoad. Commented that line of code and moved it to viewDidAppear and the app wasn't freezing.
But this gave rise to another freeze when user taps on the back button. So I recreated the segues in XCode 9 and did not set the right bar buttons on the navigation item at all. This seemed to fix the issue and there isn't any freeze right now. Hope this helps somebody else.
With iOS8, I noticed that a view controller was no longer receiving a UIKeyboardWillSHowNotification, when it previously was with iOS7.
Here's the scenario:
1.) View Controller A is displaying a keyboard, and pushes View Controller B without resigning first responder
2.) View Controller B has a control that becomes first responder during its viewDidLoad call, while it's being created by VCA, before it's pushed onto the nav controller
3.) If VC A is NOT displaying a keyboard when pushing B, the notifications work fine. However, if A is still editing when pushing B, then B does not get a keyboard will show notification.
Without the keyboard notification, VC B is not resizing / repositioning and does not look right.
The workaround I'm using until I find a solution is to do the following from any view controllers that might be editing when pushing another view controller that might be editing:
i.e., before pushing another view controller, be sure to call:
[self.view endEditing:YES];
While it works, it doesn't seem good that the view controller (B) can be 'broken' by the state of the app prior to displaying it.
Question: Am I doing something wrong here?
As far as I can tell, one of 3 things are possible:
A.) I should be getting the notifications, but I'm not b/c I'm doing something wrong
B.) I should be getting the notifications, but I'm not b/c of a bug
C.) I can't rely on always getting the notifications...But if I don't get the notifications in VC B when it appears, I need to be able to get the keyboard dimensions of the displayed keyboard without relying on the keyboard notification info. All the apple docs say to use the notifications though (as far as I can find).... which points back to options A.) or B.).
I can create and upload sample code later tonight / early tomorrow to try and isolate / for you all to test/reproduce to see what I'm doing.
I can see the same issue with iOS8 / xCode6 (works with iOS7 and xCode5). In my case, I'm observing a systemStatus property on the model in my AppDelegate so as to log the user out and bring the user back to the login screen when the user logs out from anywhere in the app. I'm doing that by setting the window.rootViewController to the loginViewController in my App Delegate observeValueForKeyPath: method.
This works fine on iOS7 / xCode5 but on iOS8 / xCode6, I loose the keyboard in the way. Looks like my loginViewController might be registering for keyboard notifications (in its ViewWillAppear method) before the window's rootViewController switch is complete (in iOS8) thus registering to the old window's notification center...
I moved the registration for keyboard notifications to the ViewDidAppear: method instead and that seems to fix it but somehow this seems to be called twice for some reason.
My iPhone application has just suddenly changed behavior and I have no idea why. I have a small button and it is now only firing on touch up outside and not touch up inside. I'm not aware of anything I changed that may have caused this.
As you can see from the image below, it is correctly wired for touch up inside to the onAdd selector.
Any ideas on what could cause this behavior?
Check GestureRecognizers, other IBActions in this view. Try to link up event with touchUpOutside and check is it working ok, then revert to Inside and check behaviour. Use NSLog in methods to see what's firing on tap. Without sample code I can't say much more.
I'm having some trouble figuring out how to use the Storyboard correctly. My main issue being Modal segues. I have a viewcontroller which I'm trying to display modally (far right in image below). But it just isn't showing. The prepareForSegue is firing correctly.
It does work when I change the segue from a Modal to a Push though.
I'm calling the segue using
performSegueWithIdentifier:#"FirstRunSegue" sender:self
Here is the visual segue setup I have at the moment
When I hover over the Excaimation mark, the following error is displayed:
I am kind of new to Storyboarding, so I'm hoping that someone could explain why the modal segue isn't working and how I would get it to work. The nasty thing is that it is a requirement for the viewcontroller to be in the Storyboard, otherwise I'd just initialize the controller and display it manually.
Regards,
EZfrag
Edit 1:
OK, I managed to figure out why the segue is not being displayed. It is kind of stupid, because it works for a push. It seems that I cannot call a modal segue from the appdeletegate's startup function. Push works fine, but not modal. Confirmed it with a new project.
Is there someone that can explain why this is so?
Regards,
EZFrag
You can only use the push segue with a UINavigationController, but it looks like you are trying to use it between two regular UIViewContoller. If you want to change the way the animation looks, use a custom segue and write your own transition.
I am having two controllers like
firstController and secondController
When am in firstController am clicking on home button its going to background state,
but, when am again enters to foreground i need to show secondController instead of firstController.
For that I am implementing code in forground to navigate to secondController its navigating but first its showing firstController and then its showing secondController I need to avoid that how to do am not getting.
Please anyone help me to solve this.
Thanks in Advance.
Regards,
Sai.
When your app goes to the background, iOS takes a screen shot of it's state. Therefore when you push your controller at the didEnterBackground stage, it won't make a difference at next activation whether you pushed another controller or not - the screenshot of second controller will be shown regardless.
Now, the good practice is to hide sensitive information when the app resigns active in the willResignActive app delegate. You could also try pushing your secondController when the app resigns active but then you will need to keep track of whether it ever went to the background or not and push the firstController when app becomes active again (in case it never went to the background)
Hope this explanation makes sense