I have iPhone as below.
What I want is click Refresh button on clicking the Delete button ** programmatically**.
Note: I have provided tag also to Refresh button.
I assume u have delete and refresh actions say
-(IBAction)deleteAction:(id)sender
-(IBAction)refreshAction:(id)sender:
Now on delete action call refresh action simply like this:
-(IBAction)deleteAction:(id)sender
{
[self refreshAction:btnRefresh]; //provide refresh action along with refersh button
//I mean here act according to refresh method.
}
Related
when I use segue to go back in some part in my app this unnecessary function appear.
I try to cancel it by write
navigationItem.hidesBackButton = false
but it cancels only the navigation controller auto generated back button but it isn't cancel the auto generated swipe up go back function.
In my Apple Watch app, one of my interface controllers has a Cancel button at the top left corner. In my case, once a particular action is completed, I don't want the user to go back to the previous screen, so I want to disable the user interaction for that Cancel button. Even if I change the title to an empty string, user interaction still stays enabled.
We can't disable the back/cancel button user intaraction but can load controller without cancel button.
presentControllerWithName("NewInterfaceController", context: nil)
presentControllerWithName this will present controller with cancel button. If we use like below won't get the cancel button.
WKInterfaceController.reloadRootControllersWithNames(["NewInterfaceController"], contexts: ["NewInterfaceController"])
reloadRootControllersWithNames this will make our controller as a root controller so we won't get cancel button. This is how i resolved my issue. Hope it will help you as well.
NOTE: here [ ] is the syntax. exp: ["NewInterfaceController"]
You can't disable user interaction for back button.
But you can change a bit the way you present your views to accomplish what you want.
Start with your normal view. Check if you need to show the user the login. If you do, then present the login view Modally. At the end of login you close the modal view and you're back to normal view, without unnecessary back button.
This is simbesi.com's answer in watchOS 7/Swift 5.
Presenting the new controller modally:
presentController(withName: "NewInterfaceController", context: nil)
Presenting the new controller by replacing the root controller:
WKInterfaceController.reloadRootControllers(
withNamesAndContexts: [
(
name: "NewInterfaceController",
context: "NewInterfaceController" as AnyObject
)
]
)
I am working on project where I have to add a dialog box on the click of tool bar button in such a manner when user click on the that a dialog box open with three buttons.
For Example if user click on share button then a dialog box open (pointing to that button) containing three buttons facebook, twitter, email.
Please be sure that I dnt want to use action sheet.
Please provide any sample code or any tutorial.
You could create a viewcontroller object with three desired buttons on its view. And then On the viewcontroller where you're currently on you can call presentModalViewController:animated method. Like:
MyModalViewController *modalController=[[MyModalViewController alloc]init];
....... then whereever you touch up the tool bar button you can say:
[self presentModalViewController:modalController animated:YES];
But you should not forget to call dismissModalViewControllerAnimated at some point(probably write this inside a button touchupinside target action method) on the dialog box to avoid having the modal view stuck on the screen forever. :)
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();
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.