"present view controller" not working only on iOS 11.2 - presentviewcontroller

This code works perfectly fine on anything before iOS 11.2:
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "loginView")
self.present(vc, animated: true, completion:nil)
The view is being presented from a UITabBarController
What is interesting is that viewDidLoad and viewWillAppear do get called for the LoginView but since it is never modally presented like on previous iOS versions viewDidAppear is never called.

Related

iOS 14 : app hangs on uinavigationController push action and hangs the app

In iOS14 devices, my app does not load the view controllers and just freeze the app.
self.navigationController!.pushViewController(itemDetailVC, animated: true)
On all device below iOS 14, it works perfectly fine. But here it does not load the next view controller.
While debugging I figured that viewDidAppear never gets called.
Anyone else facing such issue.
Thanks in advance.
Getting very strange problems with UINavigationController transition animations. Resulting view controllers appear broken and shifted. Unbelievable how broken it is.
The issue is due to mistakes on view controller override functions. Double check your onViewWill/onViewDidAppear. The should override the correct function
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
Logger.verbose(topic: .appState, message: "viewWillAppear")
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
Logger.verbose(topic: .appState, message: "viewDidAppear")
}
Also, if you are using a UITabBarController, make sure the same thing is done correctly there too.

How to swipe iOS emulator screen

As soon as I upgraded my local version of Appium, all my swipe logic stopped working. I moved to the non deprecated API, and but I'm till not able to observe swipes. I'm pretty sure I'm just not using the coordinate system correctly but I'm not sure how. I want to swipe vertically down the screen of an iOS simulator to refresh a list view.
Any pointers on how to treat properly swipe and why, and what the mechanics of it are?
Here is my code for swiping
PointOption fromPoint = PointOption.point(
topView.getLocation().x,
topView.getLocation().y);
PointOption toPoint = PointOption.point(
bottomView.getLocation().x,
bottomView.getLocation().y);
new TouchAction(user.mDriver)
.press(fromPoint)
.moveTo(toPoint)
.release()
.perform();
I upgraded my version of Appium and my Java client, but those improvements didn't fix the swiping.
Apparently, one must add a wait duration for the swipe to take place.
WaitOptions waitOptions = WaitOptions.waitOptions(Duration.ofMillis(500));
new TouchAction(mUser.mDriver)
.press(fromPoint)
.waitAction(waitOptions)
.moveTo(toPoint)
.release()
.perform();
This is my code it is working fine for IOS simulator swiping .
JavascriptExecutor js = (JavascriptExecutor) driver;
HashMap<String, String> scrollObject = new HashMap<String, String>();
scrollObject.put("direction", "left");
js.executeScript("mobile: swipe", scrollObject);

Dismissing the view controller in iOS mono touch

I created a button if i do click event the view must be dismissed and show the previous view. I used the below code:
partial void canceldata (NSObject sender)
{
Console.WriteLine("canceldata");
//NavigationController.PopToViewController(settrls,true);
this.NavigationController.PopViewControllerAnimated(true);
}
But this code is not working. Anybody suggest me how to dismiss the current view by clicking a button in iOS mono touch example.
It depends on how you open that controller. If it is pushed to the stack, then PopViewControllerAnimated() should be working. If it is presented as a modal dialog for example by
NavigationController.PresentViewController(new UINavigationController(new MyDialog()), true, null);
then you should call
NavigationController.DismissViewController(true, null);
instead.

Linking Storyboards Without UINavigationController

I have an iOS 6 app that I am updating to work with iOS 7 and to make it use storyboards. I am trying to use multiple storyboards so that I can break my project down into modules for each screen in the app. So far this has worked out fine but now I need to provide a way to navigate between the various storyboards while still making the work like it did in iOS 6 (but with updated artwork).
I don't use UINavigationController in my existing iOS 6 app and I would prefer not to use it as up to now I have been able to navigate back and forth between XIB's using code on UIButton tap gestures. The UINavigationController doesn't make it easy to customise how the navigation buttons look from what I have learned so far about it.
I found this very clean way of moving between view controllers that are on different storyboards https://github.com/rob-brown/RBStoryboardLink by passing the name of the storyboard in as an attribute.
But it only seems to work when UINavigationController is used. I get an error "Push segues can only be used when the source controller is managed by an instance of UINavigationController" without UINavigationController.
Is there a way to navigate between storyboards by only using the above RBStoryboardlink but without the need for UINavigationController?
Push segues can only be used when the source controller is managed by an instance of UINavigationController
This means you are trying to push a view controller to the source while source don't have any navigation controller stack.In that case, you should try to add the instantiated view controller's view as subview to the source view controller's view.
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
UIViewController *viewController = [mainStoryboard instantiateInitialViewController];
[self.view addSubview:viewController.view];
or you modally present, that purely depends on your requirement.
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
UIViewController *viewController = [mainStoryboard instantiateInitialViewController];
tabBarViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:tabBarViewController animated:NO completion:NULL];

viewDidAppear Not Firing in Tabbarcontroller>NavigationController>UITableView

I currently have a tab bar controller set up with a navigationcontroller on one of the tabs, then I have a UITableView nib set up for that Navigationcontrollers view. All of this has been set up through IB and I want to keep it that way. Kind of like this tutorial http://twilloapp.blogspot.com/2009/05/how-to-embed-navigation-controller.html
now the view loads perfectly when ViewDidLoad is called. But when I then load further views via code IE
MyApp_AppDelegate *delegate = [[UIApplication sharedApplication] delegate];
UINavigationController *nav = (UINavigationController *)delegate.controller.selectedViewController;
newViewController = [[newViewController alloc] initWithNibName:#"newView" bundle:nil];
[nav pushViewController:newViewController animated:YES];
//At this point the view works! and loads
If I try to go back with the navigation toolbar it goes back to my previous view fine
Now I need to refresh the tableview when I go back but calling viewDidAppear does not work.
I tried adding UINavigationDelegate to the same ViewController Class as the tableview and then calling - (void)navigationController:(UINavigationController *)navigationController didShowViewController:
But that did not work. I also tried adding the same delegate as the tab bar controller and adding the same navigationController didShowViewController: there but that also failed.
How do I get this table to refresh every time the view loads?
You should not have to call viewDidAppear from your code. Cocoa Touch should do that for you.
Call the table view's reloadData method to get it to refresh its contents.
Found I was missing the Delegate declaration in the Interface file. doh! also I tried that in lots of places it only ended up working when I added it to the NavigationControllers first view (my table view)

Resources