No need to save draft in MFMailComposeViewController - ios

After clicking the cancel button of MFMailComposeViewController action sheet of save draft or not is generated.
I dont want this action sheet how can i achieve that?
thanks in advance.

From documentation
Important The mail composition interface itself is not customizable
and must not be modified by your application. In addition, after
presenting the interface, your application is not allowed to make
further changes to the email content. The user may still edit the
content using the interface, but programmatic changes are ignored.
Thus, you must set the values of content fields before presenting the
interface.
First line answers your question I think.

Related

Passing data between more than 2 viewcontrollers in Swift

My app contains TabBar controller with 5 viewcontrollers. It is possible to click on a button in each of viewcontrollers which will popup another view in which user can choose a setting. The button (which was clicked) is supposed to change its background according to chosen setting in each viewcontroller. So if the user clicks on button in VC1 and chooses the setting, this information should spread into all of the other VCs so that the button has the same background.
I am using storyboards, and I know that this is easily possible between 2VCs using segues, protocols, closures... I cannot find a proper way to spread information to more than 2VCs.
The only solution I can think of is usage of UserDefaults. I would save an information about a button setting and then call ViewWillAppear in each VC, where the background of the button would be set according to the value in UserDefaults. Is there a better solution, please?
EDIT:
As #cora mentioned in the comments, I was able to solve this using Notification Center.
You have several options, including:
Pass an array of the tab controllers to your "popup settings" controller and call a "settingSelected" func in each one directly.
Using Protocol / Delegate pattern, you could create an array of delegates in your "popup settings" controller.
You can use Notification Center.
You could subclass the button and use UIAppearance proxy.
Which approach to use will depend on a number of factors, based on exactly what all you need to do (are there other "settings"? or only that button background?)
You may want to search for swift using themes to see various different approaches.
“Is there a better solution, please?”
Not necessarily. Is this in fact a user default, to be preserved between launches? Then this is exactly what user defaults are for.
If not, then at least you need some central location where information about the current button color can be stored. An obvious candidate here is the tab bar controller itself. It gets notified every time there is a tab bar item switch, so it’s a perfect candidate.
Since you have mentioned you are using a UITabbarController, you can use an instance of UITabbarController and then access .viewControllers property of it and call their added public methods to get them triggered on events that you add. Additionally, using Notification Center makes more sense to me since your code will be more readable. Sometimes Notifications can just get a little confusing for new developers who are working on your code.

How to identify which option selected on UIActivityViewController before presenting respective view modally?

I have a button on my view, on click of which I am presenting user with UIactivityViewController, to select options from Message and Mail.
Now I want to know how to identify which option was selected by user, so that I can perform custom check and modifications to navigation and status bar when presenting mfmailcomposeviewcontroller modally?
Also, I want to implement other checks whether device is capable of sending emails or not, this can be done only if I am able to determine, if user selected Mail option from UIActivityViewController.
As far as I know you can't do this with the default built-in activities. All you get is the completionHandler which only gets called once the action is cancelled or completed. If you want more granular control you can create your own activity and implement it yourself.
The built-in share options are also disabled automatically if they are not usable. If you need to, you can perform extra checks and if you want to disable a particular activity, use the excludedActivityTypes property of your UIActivityViewController.

MFMessageComposeViewController disable add recipients button

I have a MFMessageComposeViewController witch i pre define its body and recipients fields.
I want to disable the add more contact button "see the attached screen shot" because i just want the user to send this message to 1 pre defined number.
How can accomplish that. Thanks.
From Apple documentation of MFMessageComposeViewController
Important: The message composition interface itself is not
customizable and must not be modified by your app. In addition, after
presenting the interface, your app is unable to make further changes
to the message content. The user can edit the content using the
interface, but programmatic changes are ignored. Thus, you must set
the values of content fields, if desired, before presenting the
interface

AlertView with Checkbox Control in iOS

I want to display an alert view dialog in ios with usual title, message and two buttons + additionally I need a check box with message like "Always show this". In apple HIG document, they stated better to use an action sheet or view controller instead of displaying more controls in an alertview. Any alternative options are there?
Thanks in advance
You can create Custom View in which you can you all the required control and if you want to show the you can also use nice animation to show them and also you can set some good graphics as well. So the best way is to create CustomView.
All the best !!!

How to send email message from IOS application using 2 Views?

I am an IOS noob and this may be a dumb question, so here it is. I have two views. View A and View B. View A has my textField (for my message) and View B has my send button. Is it possible to send text inputed in View A from my send button in View B? Or is there a better way to do this?
Basically what I am trying to do is share a message using a menu. After the user clicks the send message a popup will display asking the user how to send. (IE: Send as Email, Share on Twitter, Share on Facebook, or Cancel).
My FIRST VIEW
My SECOND VIEW
Also just so I am clear. I don't expect anyone to solve it just wondering if anyone has ever done something like this before. If you want to provide possible solution that would be awesome. But really, more or less, I am looking for some insight.
Question: "Is it possible to send text inputed in View A from my send button in View B? Or is there a better way to do this?"
Answer: Yes, it is possible. Here is a tutorial which contains an explanation of how to send an email from an app: http://blog.mugunthkumar.com/coding/iphone-tutorial-in-app-email/. In the toolbar in the first view you might consider using a standard system image, UIBarButtonSystemItemAction, instead of "Send Message." You might also consider using a UIActionSheet instead of the second view. Apple says, "Use the UIActionSheet class to present the user with a set of alternatives for how to proceed with a given task."
Yes this is possible through several methods. The most OO and IMO the best way will be to create a custom init method on ViewB.
Something like -(id) initWithEmail(NSString* email, NSString* message)
It is easy if all your widgets (the textfield, the button and the action sheet) are all ivars of the same view controller.
So, in the same controller, the button will trigger the selectSendingMethod which will display the pop up and each button of this sheet will call an adequate method.
That should solve your problem.

Resources