How to send sms, detecting text in textview? - iphone

I want that when user clicks on certain text,(like call, sms, mail), then corresponding activity should happen ie, when user clicks on call then an action sheet should appear with actions whether you want to save or call etc, similarly for sms and mail.I used textview and gave detection for numbers and email. So for call and mail it is working fine. But how to detect for sms?Because when I give number detection it will automatically show call action sheet ie save or call or cancel.But I want following action sheet, which sms, open, copy, cancel:
I tried using sms//"91123456", but it is not working. I know I can directly launch message picker but do not want this, I want to show default action sheet.I tried this in html and it is working but I want to do in native.

Did you try textView.dataDetectorTypes = UIDataDetectorTypeAll;?
For more data detector types see this UIKit Data Types Reference.

Related

How can I control isUserInteractionEnabled status of a button remotely in Swift?

I wish to know how something like remotely altering an app's content or an app's UI Elements would look.
I have already been using remoteConfig to alter certain content (for instance, UILabels) remotely, though the response time is variable and not immediate.
What I wish to know is, how can I use Firebase/Cloud Firestore such that I can remotely change the status of my app. For instance, if I want to disable userInteraction for a particular button remotely, how can I go about that? Or if I need to change an image displayed remotely, what knowledge do I need to do this? RemoteConfig is unable to achieve these 2 particular tasks.
There is no such thing as changing an app remotely. The app is in sole charge of itself. If the app gets its data from firestore and there is something about that data that makes the app want to disable a button, it disables its own button.

swift - how to prevent two touches at the same time

For example, I have 2 buttons Change email and Change password, and each of them call functions with Alamofire request, and responce data should reload both the UI and data scheme.
The point is that this PUT requests change not only servers's data, but generate new token and get updated user's profile.
And when pressing buttons at the same time, at the same moment touches begin and end, app crash after parsing requests.
I'm blocking another UI elements(like textfields), I was trying to block another button, but when press it together, it's not works.
So how can I prevent the same time touch? I'm not good at OperationQueue, maybe thats'the way? Is there an option to check if operation not first at the queue and kill it?
Set isExclusiveTouch of your UIButton to true in order to trigger only one button action in a specific time.
This code will get all the buttons contained in the view and set the exclusiveTouch to true:
self.view.subviewsRecursive()
.filter { $0 is UIButton }
.forEach { $0.isExclusiveTouch = true }
This problem with the UIResponder object is very usual. However, your problem description is not clear and your implementation seems not so good.
Here, to resolve this quick touch event problem:
Your solution is debouncing the action event of UIButton.
Debouncing also helps to prevent multiple executions when a user mistakenly pressed a button (or any UIResponder object) multiple times so quickly that even the UI was not blocked till then. Following article may guide you more regarding the same:
Debouncing to tackle repeating user action

How to Detect if WebView is showing a specific Website on iPhone

I am new in iOS development and trying to make a button called backhome which is only visible when the user tap on the changes the native Website I set in the loadRequest.
Now my question: Is there any way to detect if the user leaves the website I set for e.g in a if statement?
Set a delegate for your "UIWebView" object and then write a method to respond to:
webView:shouldStartLoadWithRequest:navigationType:
The request parameter in that call has a URL and from there, you can tell if the user has left your default website.

"Send" button popup not appearing correctly

I'm using the Facebook Like/Send buttons along with dynamically generated HTML (loaded via AJAX requests). I've found that even though the Send button works fine when the element exists on page load, dynamically created Send buttons aren't working correctly. Clicking the button activates it and the button greys out, but the popup doesn't appear.
Here is a demonstration of what is happening: http://jsfiddle.net/Daniel15/VxpSj/
Any suggestions?
Thanks!
Yes, I can confirm the problem from your fiddle.
function addLikeButton()
{
// […]
FB.XFBML.parse(newEl);
document.getElementById('container').appendChild(newEl);
}
For some reason, this seems to be “the wrong way around”. Reverse the order of these two lines – put the new element into the DOM first and let FB.XFBML.parse parse it afterwards, then (from my test with your fiddle) it seems to work in the desired way.

MFMailComposeViewController and cancelling "save" action sheet?

i am using MFMailComposeViewController inside my iphone app. I notice that if i enter any text in the body and then press the cancel button, i am prompted with an action sheet with an option to save/don't save the unsent message. I have two questions:
can I programmatically prevent the "save/don't save action sheet from appearing? MFMailComposeViewControllerDelegate doesn't appear to have anything along those lines
if i do save, where is the mail saved to? i looked in my mail accounts and didn't see anything saved in any of the "draft" folders.
No, you can't avoid the action sheet appearing. It's been added in iOS 4.x to, precisely, avoid tapping on the "Cancel" button inadvertently when writing a long email, which I think it's a good idea.
It is saved in "Drafts" folder of the account used to compose the e-mail (normally, your "default account" as it is registered in the Settings of your device). I've just tried using a couple of apps and it works.