Swift 4: Click button to next View Controller but the new page's animation is "cover vertically" instead of "shifting" to next page - swift

I am newbie of Swift 4 and I am trying to simply click a button and go to next page.
So I add a button in the first page and another view controller. Then I drag the button to the next page to create the "transaction". However, the animation of the transaction to pop up the next page from bottom, as shown in the image below. What I expect is to shift horizontally from current page to next page. Where did I do wrong? How can I achieve this?

Select the first view controller and choose Editor > Embed In > Navigation Controller. Make sure your segue is Show (Push).

Related

Swift: Pop from one tab to another tab

Have a tabBar Application in which there are five tabs and in one tab have added back button and i want to pop back using back button. how can it be done? have tried below code and it doesn't work
self.navigationController?.popToRootViewControllerAnimated(true)

Won't add navigation item to navigation bar in xcode

I'm trying to create a back button on my navigation bar in x code. However when I drag it across from the objects library to the navigation bar in the storyboard it doesn't come up.
OK So this is crazy but...
Click on the navigation bar and in the attributes inspector, Just Type something in the field marked Back Button. Then in the scene hierarchy you'll see the button, though it won't yet appear on your navbar. In the hierarchy, drag the button onto the Navigation Item and viola it appears. Now to make second one, hold option and copy the first one. If you try to add one from the object browser, you'll lose the first one.
If done properly, the first will show up on the right and the second on the left.
Good luck.
This happens when the navigation is not set up correctly, as dbajkovic mentioned, if you do not have a navigationcontroller, it will not work. Your scoreboard should look like this:
You can not add the button to the left, only to the right.
#Jonathan Thompson: I came across your post and since I just learnt something new, I am going to add it as a response to your question.
There are two separate buttons - Back button and Bar Button. Back button has a reverse (right to left) pointing arrow and a Bar button is a regular rectangular button. The following describes how your could implement them in your program:
Back button:
On the root view controller, ctrl + click on button and drag it to the view controller you are trying to connect it to. When you are given an option to select from, choose Push, not modal. This will automatically add a back button on the next view controller. (Run the program to confirm it.)
Bar Button: (Credit: dbrajkovic)
For adding the bar button, click on navigation bar of the navigationViewController you are interested in. Under Attributes inspector, type some name in Back Button and hit enter to confirm. Open document outline and locate the viewController you were working on. On the left side of Navigation Item locate the disclosure triangle. Click on the Bar Button Item. Ctrl + click + drag the button to the navigation bar of that viewController. You can choose whether to place it on the left / right side.

NavigationBar Right Button Problem

I have a navigation bar in my app. The below pictures are in the order of navigation.
Problem I have is, on clicking the "Main" button , I am able to perform the action and goto the required screen , but the navigation bar does not look like the first on (with Menu as left button). Instead it look like 4th image. How to make it look like first image so that I can make the user to navigate to "Menu" screen by clicking menu button ?. Thanks for the help …!!!
If I'm understanding this correctly, you may have pushed the first view controller (The one from screenshot 1) when clicking on main which is why you see "lens" in the back button. That back button takes the title of the previous view controller in the stack. What you want to do is pop to the first view controller when they click on Main using either popToRootViewController or popToViewController:animated

How do I reset UIScrollView to Zeroth Page/Index when Clicking on a Tab Bar Item?

I have a tab bar application with 3 tabs. The first tab loads a UIImageView that is nested within a paginated ScrollView. If the user were to scroll through the pages for a bit, then click on another tab, and then click back to the first tab, they would return to the last page they scrolled to within the ScrollView.
How can I have make my first tab bar item resets to the initial image/page in my UIImageView every time it's clicked?
Thanks!
Have a look at :
UITabBarControllerDelegate. You have a callback didSelectViewController.
One solution would be for your ApplicationDelegate to get this callback and inform your firstviewcontroller from the first tab to call a method that would just take the user to the first page.

UI Automation :- How to click button using javascript of a screen which is not the main screen (iPhone)?

want to click a button through javascript for testing purpose. i am able to click the button which is on first page, but dont have idea how to click button on second page which comes after clicking button on first page.
You just need a reference to that button on the second page -- so you repeat the process from the first page. Probably, you did something like this (this code is from my app using a tab bar controller):
// Now tap the add button
var navBar = mainWindow.navigationBar();
navBar.buttons()["Add"].tap();
// Now the app loads a new page
// Get the nav bar again (it would have changed after the tap above)
navBar = mainWindow.navigationBar();
So, the answer is easy -- just call back to the same functions, they will return whatever's on screen at the moment.
First you have to ensure that the button is accessable. Either set the Accessability property in Interface Builder (Identity Inspector - last Tab) and give the button an appropriate Accessability Label. If you don't use Interface Builder you can set the property on the button programaticaly.
Now in the script you can call
mainWindow.buttons()["name of the accessability label"].tap();
mainwindow is:
var target = UIATarget.localTarget();
var application = target.frontMostApp();
var mainWindow = application.mainWindow();
Make also sure that the button is visible. The button has to be the deepest element in the view hierarchie which is marked accessable. If the view containing the button is enabled as accessable, it would hide the accessability of the button (which is a subview).
You can log all visible elements in the screen by
mainwindow.logElementTree();
Moreover, you always can use one single script. The mainWindow.elements() references the view which is shown at a certain moment.