WKInterfaceController top right button - apple-watch

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.

Related

Content of UIPopoverController slides out of view when Keyboard is dispatched

I have an iPad app who's login screen looks like this (top of image clipped because of sensitive info):
When the user taps "Log In" button I load a UIPopoverController with some buttons:
When the user taps "Email" button, I release the first popover and create another one with two text fields:
Looking good so far, but when the user selects the text field in order to enter text, both of the UITextField controls slide off of the top of the PopoverController, like this:
I am using storyboards/segues for these popover controllers, with a little hand coded stuff to handle device rotations. I am using Autolayout and both of the UITextFields are pinned to the SuperView Top and Leading edge. That is all.
If I move the buttons up more towards the top of the screen (out of the way of the keyboard), this behavior is still present.
What is triggering this and where can I override its behavior?
Did you set the ContentSizeForViewInPopover for the view controller in -viewDidLoad showing textfields?
[self setContentSizeForViewInPopover:CGSizeMake(200, 200)];

IOS - Prevent page curl in PageViewController

I have a UIPageViewController that displays images. I've set an opportunity to mail a desired image that the user is currently viewing. For this if user taps once the central region of the screen a tab bar appears with a bar button item titled "Mail". And when this button is pressed the imaged is attached to a mail composer. But I have a little problem here: As the bar button is on the left edge when I tap it page curl takes place and I can't get the mail composer-more precisely I can't get the button tapped. How would I prevent page curl when this button is pressed?
There are several ways you can overcome this problem. The second solution is easier to implement.
The first one is to access the gesture recognizers defined for the page view controller (from the "gestureRecognizers" property, which returns an array of gesture recognizers), search for the "tap type" gestures and then assign them a delegate to your view controller. This delegate will implement the method gestureRecognizer:shouldReceiveTouch: and will check if the tap occurred in the tab bar position and will return NO in such case, so the gesture will not be triggered. Your delegate will return YES if you still want the tap but it is outside the tab bar region.
Another possibility is to define a new tap gesture recognizer and assign it to the tab bar. In such case when you tap over the button (which is in the tab bar) the target selector that you assigned to your tap gesture will be triggered. Clearly, this selector will do nothing as its purpose is just to avoid propagation to the gestures which are beyond it (this is the default behavior).
I think my answer came too late from your request, so if you have found a better solution please post it!

What is the view or thing called that pops up in the photos app when you click the leftmost button at the bottom of the screen on the iPhone?

I want to implement this on my app. I want to search for tutorials on this topic but I don't know what its called. Can someone please tell me what its called? Eg. In the photos app in iPhone, when u click on the left most button at the bottom, a screen pops up from the bottom giving you options to either email image, set as wallpaper etc.. So, once again, what is this called? Thanks
That is a UIActionSheet. Check out the UIActionSheet Class Reference.
Basically you create one with the designated initializer -initWithTitle:delegate:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles: then send the -showInView: message to display it. You'll have to set yourself as it's delegate in order to handle selections made by the user.
The button is the 'action' barButtonItem type.
The button then opens a modal sheet. Opened with something like:
[self presentModalViewController:menuViewController animated:YES];

Add a custom back button to Navigation Bar using MonoTouch

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);

Where should I "save" changes in my iPhone view to 'create new' of an object?

I have a view that creates a new core data managed object, and fills in all the required properties and also allows optional ones. I originally had a "Done" button on the top left, and when that was pressed, I validated the object then saved and removed the view.
Now I have an edit/done type setup on the top right, so sometimes there are two identical "Done" buttons on the top of the view. I want to switch the left side button so that it just has the normal "Back" button, then somehow validate and stop the view from being removed if it doesn't validate. I can't find any way to capture the method called by that back button and modify it, and viewWillDisappear doesn't work cause there's no way to abort the disappearing.
How can I make this work? I need to validate this, then save, then remove the view if validate and save worked only.
It sounds like your view is a perfect candidate to be pushed modally instead of through the navigation controller stack.
Push the view that creates your NSManagedObject modally:
[self presentModalViewController:yourViewController animated:YES]
Then continue to use your top right EDIT/DONE button for editing/validation as you currently are and when validation is successful simply save your object and dismiss the modal view controller from the parent view controller:
[[self parentViewController] dismissModalViewControllerAnimated:YES];
For more details check http://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html#//apple_ref/doc/uid/TP40007457-CH111-SW14
If you still want to use a button on the left hand side perhaps you can change the right button to say EDIT/CANCEL and add a DONE button on the left side that is only visible when you're not in EDIT mode. If appropriate you can point the DONE button to run through the same validation process before dismissing the modal view using the code above but it probably makes sense that the EDIT/CANCEL button takes care of it.
I hope this helps.
Rog
There is no documented way to intercept the standard back button of UINavigationController. If you want this functionality, your only option would be to customize leftBarButtonItem with a custom button.
When the user taps that button, you can first validate your object and then call popViewControllerAnimated:.
It's hard to mimic the look of the built-in back button, though.