My app has a main screen where i have button to go to login screen. On pressing login button it goes to second screen which is login screen.
In the login screen i have a submit button which is inside a table view.
I want to tap this Submit.
What approach i should use. Or more precisely in same java script hot to access the elements of second scree.
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.
Get the tableView object of the window, then get the cells of that tableView. Now grab the buttons array of the cell with the submit button and tap the button. Something like that:
var submit = window.tableViews()[0].cells()[2].buttons()[0];
submit.tap();
Related
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
I am developing an application which has 4 views and use navigation controller to navigate through. The first view is login interface. I just want to display login view when user press home button from second view. I have tried to use popToRootViewControllerAnimated in applicationDidEnterBackground. This does not work. Because I need to do this job only user press home button from second view (Second view contains MKMapView).
Can you please let me know what is the best option for this job? Basically I just need to check what view I am currently on.
Many Thanks
You could log a BOOL variable that the viewDidAppear function on your second controller sets to YES. And when you leave that view set it to NO. In applicationDidEnterForeground check it. If it is YES then the user left while in the second view.
Just want to confirm this, as I'm trying to learn monoTouch alone..
I have a view which I navigate to using NavigationController.PushViewToController(). On the destination view, I have a Navigation Bar. I can add a button to the bar and use code to push to another view (I happen to know where Back is), fine.
Is there a existing "back button" control? Or a way in to code to change the existing back button to say "Go back"?
In Interface Builder I can see there is a property on the navigationItem called "Back". When I add text to this I can see a new BarButtonItem added to the navigationBar. However I never see this button when I navigate to the view in the simulator. If I try to drag the item onto the view manually, the "Back" text is cleared and the button is treated like a custom button.
Do I always have to manually code the back button?
The default back button (the one that takes the name of the previous controller) cannot be customized. But you can hide it and replace that button with a new one.
If you have a controller, you can do that on the viewDidLoad method. Overriding this method you are sure that all the elements have been set.
// allows you to hide the back button
NavigationItem.SetHidesBackButton(true,true);
// allows you to create a new customized button
NavigationItem.LeftBarButtonItem = new UIBarButtonItem(...);
UIBarButtonItem takes an handler that you can use to control the navigation.
In the handler you can do this:
NavigationController. PopViewControllerAnimated(true);
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.
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.