I have a a view controller to create an item within my app, once the required text field in the view has been completed you can press the save icon in right hand navigation button.
The UIBarButtonItem is created as a property of the view controller thus:
let add = UIBarButtonItem(title: "Save", style: .done, target: self, action: #selector(save))
The action simply saves the item to Core Date and pops the view from the navigation controller.
The add button is programmatically added to the UINavigationItem and setup in viewDidLoad.
One of the fields is a required text field so I have the following code to determine if its possible to save the item:
#IBAction func editingChanged(_ sender: UITextField) {
add.isEnabled = sender.hasText
}
If the required field is populated the add button is enabled, otherwise it is not.
When testing on an iPad (iOS 15) after typing some text in to the text field and dismissing the keyboard, although the add button shows as active it actually wont execute the given selector to save the item until the keyboard is displayed again.
All of the other items in the view, such as scroll wheels and segmented controls continue to work as expected when the keyboard is dismissed.
Is there a known reason that dismissing the keyboard would disable the right nav button without setting its state to disabled? or that would prevent it from executing its associated action?
Or have I simple set something up incorrectly?
For reference I am not "moving" or adjusting the view or controls in the view to accommodate the keyboard.
The App targets iOS version 12.
Update
The left navigation button works as expect, it displays the previous view in the navigation stack.
The right navigation button looks as though it is responding to taps, just not executing its attached action.
Why would the present or absence of the keyboard impact the right navigation button performing its associated action?
Related
Trying to implement core data edit record.
Current Status : In the view did Load I have aded
self.navigationItem.rightBarButtonItem = self.editButtonItem
The edit button is appeared on the top left navigation bar. By clicking the edit button the red busy icons are appearing. if I click the icon then delete button appears. When I click the table view cell then nothing happens.
Desired Response: I want to call the edit table view controller so that the record can be edited.
I have added didSelect but it is only being called when the table view is not in edit mode.
How to call the edit view controller if I tap any table view cell with the edit icon appearing on the left side.
For example in the clock app. When you click the edit button the red icons appeared on the left side. If we want to edit the time then we can tap the table view cell i.e. alarm time and a view is posed up to edit the time. Same functionality is required.
In order for the didSelectRowAtIndexPath to work during editing, you have to set the allowsSelectionDuringEditing to true
On WKInterfaceController, is there a way to add a button (such as 'Done') at the top right corner of the watch screen instead of the time?
No. You can specify a 'title' for a presented modal controller, but it will always appear on the top left corner.
If the modal interface controller does not have a title, its title is set to the string Cancel by default. You can set the value of this string in your storyboard or change it at runtime using the setTitle: method. When the user taps the title string, WatchKit automatically dismisses the modal interface without taking any further actions.
Interestingly, Apple does happen to display Done on the right during modal text dictation. You could submit an enhancement request asking to substitute a 'title' in place of the time.
I currently have a segue that presents a VC modally in PresentationStyle.PageSheet. I have done this both programmatically and with just the storyboard. I get the same result with both approaches, the modal pop over presents itself but does not show any content inside the UIView from the VC. It will only show the background color of the view and that is all. I also want to point out that everything is displayed if I do a default modal segue (full screen) but fails with page sheet presentation style or with using UIPopoverController. Here are some screen shots that show what I am talking about.
This is what it looks like in the storyboard:
This is what it looks like in the simulator and on an actual ipad:
Here is what my coding approach looked like:
#IBAction func addPickUp(){
var addPickupVC = self.storyboard?.instantiateViewControllerWithIdentifier("pickup") as AddPickupViewController
addPickupVC.modalPresentationStyle = UIModalPresentationStyle.PageSheet
self.presentViewController(addPickupVC, animated: true, completion: nil)
}
This written in swift for ipad ios8.
What am I missing here? Any constructive feed back is appreciated!
EDIT: Here is the document outline of the VC that is to presented modally.
Your code for presenting popover is correct.
Probably there is problem with AutoLayout constraints.
As you can see your popover is presented but label is missing.
Remove your AutoLayout (they will be auto generated) and see if the label will be visible now
Try to add new label. Drag and drop it, and don't specify any constraints
Debug your view
Click "Debug view hierarchy" button at the debug panel
Now you can see your view hearty. Select your label, if it's present and see it's constraints.
Check your AutoLayout constraints and Label is present in correct Size Classes
Size classes is shown bellow UI designer. In my case it's (Any Any).
It means that it's for all sizes and all devices.
Also check that your constrains is not removes at runtime.
You can see it on inspector in right side.
In the storyboard, you can simply control drag a connection from your button to your presented Viewcontroller. There's no reason to have a #IBAction for this. If you use the InterfaceBuilder approach you can optionally set the presentation style on the segue to PageSheet.
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 added add(+ symbol button) button to my navigation controller.
When I click it a view appears from bottom. I added a navigation bar and two buttons to it.
One save and one cancel button. And the view have one textEdit box. After editing I can save or cancel. If I touch cancel I need the view to disappear like it should go down again.
I think all iPhone , iPodTouch users use it. Like when they touch Add item then a view appears from bottom and when they cancel it goes down again. How can I make in this way in my application.
Maybe you're talking about a UIActionSheet?!?
http://developer.apple.com/IPhone/library/documentation/UIKit/Reference/UIActionSheet_Class/Reference/Reference.html