ECSlidingViewController 2 not working XCode 7 iOS 9 - swift

The unwind segue to the menu view is no longer working on XCode 7 with iOS 9.
The only way I got it to "work" is by changing the type of segue in the storyboard to an ECSlidingSegue from the default UIStoryboardSegue. the ability to change this in the storyboard for unwind segues seems to be new to XCode 7. When changed to the ECSlidingSegue it only shows the menu view itself and the view it was supposed to shift to the right (but still keep on the screen) disappears. All other segues seem to be working and I can confirm that all was working correctly in iOS 8 and XCode 6.
Any ideas why this would not be working?

It looks like ECSlidingViewController hasn't been updated for a year now.
In some of my apps I am using MMDrawerController which seems to do exactly the same and I can confirm that it works with iOS 9. And it is updated on a more regular basis. If you are interested in trying it you can check it here

No, but until it's fixed, you can show the menu from code:
- (IBAction)menuButtonTap
{
ECSlidingViewController *slidingViewController = (ECSlidingViewController *)self.view.window.rootViewController;
[slidingViewController anchorTopViewToRightAnimated:YES];
}

#IBAction func menuButtonTapped(sender: AnyObject) {
let slidingViewController = self.view.window!.rootViewController as? ECSlidingViewController
slidingViewController?.anchorTopViewToRightAnimated(true)
}
I managed to get it working correctly using swift by attaching each of the menu buttons in each of the view controllers to an IBAction function. I then put the code as it is above into each of these IBAction functions. The code uses the current instance of ECSlidingViewController (the current view) and then calls anchorTopViewToRightAnimated in order to correctly assign the current view that is being pulled to the right.

Related

becomeFirstResponder is not showing keyboard until touch of any UITextField at least once

Possible solution at the end.
I am developing a UIViewController with three UITextField. The function to open the keyboard when the screen is presented was working for 3 years non-stop, then after the iOS 13 it stopped working. The same script is still working normally on iOS 11 and 12.
To make it work again I need to click to any UITextField (it doesn't need to be on the same screen) in the app. After that, all the UITextField in my app are triggering the keyboard.
No, I am not using the hardware keyboard and the problem also happens on a real iPhone X.
To open the keyboard I am doing this:
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
DispatchQueue.main.async { [weak self] in
self?.textField.perform(
#selector(self?.becomeFirstResponder),
with: nil,
afterDelay: 0.1)
}
}
I tested it very well in multiple devices, also recorded a video showing a iOS 12 and iOS 13 running the same binary side by side and the function not working on the iOS 13.
Again, it only don't open the keyboard if the user NEVER click in ANY UITextField (or anything that opens the keyboard). Once you clicked in this type of component, the keyboard start opening again.
The app uses UIScene on iOS 13. Could this be the problem?
Is this a known bug on iOS 13? I am not sure how to solve this.
My setup:
macOS 10.15.2
Xcode 11.3
Swift 5
Screenshot of the problem, same binary, same actions to go to this screen, different behaviour (the info from the UIViewController at the back was hidden manually):
Possible solution:
If you are using Intercom in your project. Simply add Intercom.logout() when your ViewController starts. After that, the problem is gone.

How to set initial view controller after button tapped

I have an app that has a begin journey activity and a choose category activity. I want to make it that after the user presses the start journey button he won't be able to return there or be able with a certain button.
Set the next viewController as the root viewController as described here: How to set the rootViewController with Swift, iOS 7
It seems like you’re looking for the root view of the app to be changed to the beginning of the journey, rather than the initial home screen. This can be done by setting the rootViewController property of the app’s main window, UIApplication.shared.keyWindow.
This can be done using the following code block:
let viewController = JourneyViewController()
guard
let window = UIApplication.shared.keyWindow
else {
return
}
window.rootViewController = viewController
Please note, I work in Xcode 11 beta with iOS 13. My apologies if this doesn’t work with older versions of iOS/OS X.

Come back to the tabBarController, swift

Currently on my viewController : Upload, my button send the data to my database only if all the information are filled out, and I come back to the preview view (table View) with :
self.navigationController?.popViewControllerAnimated(true)
I would like, if it is possible, to come back to my main view on the tabBarController. I tried many things, like directly on the storyboard with Present modally segue to "TabBar controller", but I come back to the TabBar without sending my data to the database and without checking in the information are filled out..
How can I do it?
Thanks!
UITabBarController has a property selectedIndex with which you can switch the selected tab. So on completion after dismissing the UploadViewController you can run:
self.tabBarController?.selectedIndex = 0 // Index to select
It would probably be best to create a delegate for your UploadViewController to fire a function to do all the work in your previewVC on API call completion.
(Super late response...in case someone has similar questions, presumably in later version of Swift, such as mine which is Swift 5, iOS 13.2). Steps:
Be sure to set an id for your UITabBarController storyboard, e.g. "TabBarViewController"
Next, add the following to an action that has already been connected to a button:
let ID_TABBAR = "TabBarViewCOntroller"
#IBAction func returnToTabbar(_ sender: Any) {
let tabBarController = self.storyboard?.instantiateViewController(identifier:ID_TABBAR) as! UITabBarController
self.navigationController?.pushViewController(tabBarController, animated:true)
}
Referenced from one of the responses from this post.
Update: In case your Tab Bar View Controller also happens to be the root view controller, the two lines of the code in the returnToTabbar method above can be:
self.dismiss(animated:true, completion:nil);
self.navigationController?.popViewController(animated:true);
(ref.: See answer here, for Swift4 but works just fine in Swift5)

ELCImagePickerController shows just black screen + navigation bar with Swift

I am trying to implement the ELCImagePickerController, but when I try to present the picker, just a black screen shows up with a navigation bar at the top. I moved all files(also the xib) into my project :/ Is this a problem because of swift/ios8 ?
var imagePicker:ELCImagePickerController = ELCImagePickerController();
self.presentModalViewController(imagePicker, animated: true);
That's because you are just calling the init method instead of the proper initImagePicker that is expected to be used (See the source here).
If you instantiate in like this it works:
var picker = ELCImagePickerController(imagePicker: ())
Note that the name is weird because of the automatic conversion that Xcode does for you of the Objective-C method by removing the init part of the name.
Also note that you don't need to specify that picker is of type ELCImagePickerController because Swift infers it automatically.
Hope this helps :)

iOS 5 issues: Navigation bar clipped after dismissing modal

I have a nice little app on the app store that does pretty well for itself. Life was great until iOS 5 came to town. Now, I have a number of issues with my app that I have no way of fixing because I have no clue what is going on, because I feel that they are iOS 5 issues, not mine.
Was there an iOS 5 conversion manual I missed? Or did they just change everything for fun, and want us to figure out where all the easter eggs were?
Here is another issue I am experiencing (that I have wasted so much time trying to fix), that DON'T EXIST AT ALL when I simply say that I want to run the app in good ol' 4.2:
Modal view
My app is a simple reader app. I have a book reading view that displays text with a UIWebView. One of the features I have been working on involves the ability to take notes as you read. This is achieved by hitting a button, and presenting a modal view. Yes, a modal view. The most simple pre- iOS 5 thing you could possibly do. Now, when I dismiss my modal view, just by hitting cancel, and simply dismiss the view, when I get back to my reader view, the navigation bar at the top is pushed up half way off the screen! This doesn't happen in 4.2, but there it is in iOS 5!
What can I do to get this issue resolved?
Thanks for your help.
Ok, I was just able to figure out what in the blazes was going on. I had the shouldAutorotateToInterfaceOrientation value set to a BOOL variable, so that when the modalView was coming back, it didn't know the state/size of the status bar. Fixed that, and the problem disappeared.
I have the feeling it has something to do with the way you present and dismissing the modalview. Apple introduced a new method to present views. May you try using theses instead of the old ones and see if it fixes your problem.
So here is what you do:
change this method:
presentModalViewController:animated:
into the new preferred method introduced with iOS 5:
presentViewController:animated:completion:
Depending if you are using dismissModalViewControllerAnimated:to dismiss your view, change it into dismissViewControllerAnimated:completion.
This methods also have completion handler which is very useful to do some extra work after the view has been presented/dismissed. Maybe that also helps with your other issue. Let me know if that might helped.
A major change in iOS 5 is that the navigationController property of UIViewController is no longer set for modal views. Instead, there is a new (not present in iOS 4) parentViewController property. So where you're using navigationController in a modal view you need to change the logic to something like:
UIViewController* parent;
if ([self respondsToSelector:#selector(parentViewController)]) {
parent = self.parentViewController;
}
else {
parent = self.navigationController;
}
(That's from memory, so I can't guarantee that every t is dotted and every i crossed.)
I was seeing this same clipping problem.
I found out that the reason for my issue was that I set the content size within the modal dialog (something I did for my iPad layout), so removing these two lines seemed to fix the issue:
CGSize size = CGSizeMake(320, 480);
self.contentSizeForViewInPopover = size;
I thought the problem was fixed but it wasn't. After reviewing the code some more, cleaning the build, and retesting it turned out to be a shouldAutorotateToInterfaceOrientation which would return NO for all orientations, for a brief amount of time (flag == NO) while the app is loading (root controller). You want to at least return YES to one orientation like so:
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return !self.flag ? UIInterfaceOrientationPortrait == toInterfaceOrientation : YES;
}