I am in the middle of porting an old app to fit the longer screen of iPhone 5. I am wondering why the built-in UIActionSheet (Cancel) of MFMailComposeViewController is not aligned to bottom, as shown:
Is this controlled by the parent view? Where should I take a look into?
Use this piece of code in app delegate's applicationDidFinishLaunching method
[window setFrame:[[UIScreen mainScreen] bounds]];
If you want to open iPhone Email application, then use below code.So, you have not any need to add MFMailComposeViewController.
NSString *subject = #"";
NSString *body = #"";
NSString *address = #"test#gmail.com";
NSString *cc = #"";
NSString *path = [NSString stringWithFormat:#"mailto:%#?cc=%#&subject=%#&body=%#", address, cc,
subject, body];
NSURL *url = [NSURL URLWithString:[path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:url];
Related
Please take a look at this piece of code:
NSString *text = [NSString stringWithFormat:#"%#",
[#"Hello world!" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSString *post = [NSString stringWithFormat:#"fb://publish/profile/me?text=%#", text];
NSURL* url = [NSURL URLWithString:post];
if ([[UIApplication sharedApplication] canOpenURL:url])
{
[[UIApplication sharedApplication] openURL:url];
}
By means of this code I would like to open Facebook app installed on the device and open it on a share dialog with the text string used as a predefined text to share. But unfortunately what it does is just open my timeline. What am I doing wrong? Or is it even possible? I can't find any documentation or tutorial on how to do that properly. Thanks
There is simple way using FacebookSDK's framework. This takes only 2 minutes to go.
FBSDKCoreKit.framework
FBSDKShareKit.framework
If in your device facebook app is not installed then this will open default web browser.
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKShareKit/FBSDKShareKit.h>
// in viewdidload or somewhere else
FBSDKShareLinkContent *content = [[FBSDKShareLinkContent alloc] init];
content.contentTitle = #"Scare Prank";
content.contentDescription = #"Someone just got Scare Pranked with ♫";
content.contentURL = [NSURL URLWithString:soundUrl];
content.imageURL = [NSURL URLWithString:#“some icon url”];
FBSDKShareButton *button = [[FBSDKShareButton alloc] initWithFrame:CGRectMake(0, 0, 200, 43)];
button.center = self.center;
button.shareContent = content;
[self addSubview:button];
SCENARIO
I have an app that is a UIWebView, I make some url overriding for requirements.
PROBLEM
To make a call opening url with tel: works weird in iOS7 and iOS8, it makes the phone call direct in the background, but it also ask for the confirmation, so user experience is horrible:
[[UIApplication sharedApplication] openURL:request.URL];
SOLUTION
To solve this issue, I used telprompt. It works nice in all iOS versions:
NSURL *url = [NSURL URLWithString:#"telprompt://637****"];
return [[UIApplication sharedApplication] openURL:url];
But shows this confirmation dialog:
QUESTION
Now, I have a new requirement, to make the phone call without confirmation or prompt. So... There is some way to make a phone call in iOS omitting the confirmation prompt?
I want something like
NSURL *url = [NSURL URLWithString:#"telnoprompt://637******"];
return [[UIApplication sharedApplication] openURL:url];
NSMutableCharacterSet *characterSet =[NSMutableCharacterSet characterSetWithCharactersInString:#" "];
NSArray *arrayOfComponents = [phone_number componentsSeparatedByCharactersInSet:characterSet];
phone_number = [arrayOfComponents componentsJoinedByString:#""];
NSString *phoneURLString = [NSString stringWithFormat:#"tel:%#", phone_number];
NSString *escapedUrlString = [phoneURLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *phoneURL = [NSURL URLWithString:escapedUrlString];
What's the easiest way to share a link as a Facebook Page from an iOS app? I don't care if the solution isn't elegant, it's just for an internal tool.
You can try this....
NSString *urlString = #"Your Link";
NSString *shareUrlString = [NSString stringWithFormat:#"https://m.facebook.com/sharer.php?u=%#", urlString];
shareUrlString = [shareUrlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [[NSURL alloc] initWithString:shareUrlString];
[[UIApplication sharedApplication] openURL:url];
I'm trying to launch google maps from my iPhone application.
The launching part works fine but since the iPhone 3.1 update (i think it was around this time) I get a zoomed out map of the US and Canada rather than zoomed in on my current location. Everything worked fine originally but sometime around the update things stopped working correctly.
Here is the string I've been using. This works on my partners phone with iOS 3.0 and our iPod with iOS 2.2.1 but on my phone with iOS 3.1 shows a zoomed out map of Canada and the US.
NSString *name = #"clothing";
NSString *latlong = [[NSString alloc] initWithFormat:#"%#,%#", latitudeString, longitudeString];
NSString *url = [NSString stringWithFormat: #"http://maps.google.com/maps?q=%#&mrt=yp&ll=%#",
[name stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
[latlong stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
[latlong release];
Any help is greatly appreciated.
Thanks in advance.
This is the code I use in one of my apps and it works fine with 3.1. The parameters for Google maps are documented here.
CLLocationCoordinate2D stationLocation = ...
NSString *urlString = [[NSString alloc]
initWithFormat:#"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f&dirflg=d",
curLocation.latitude,
curLocation.longitude,
stationLocation.latitude,
stationLocation.longitude];
NSURL *aURL = [NSURL URLWithString:urlString];
[urlString release];
[[UIApplication sharedApplication] openURL:aURL];
How can I make a phone call in Objective-C?
You can initiate a call
https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/PhoneLinks/PhoneLinks.html
So this would probably work:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:12125551212"] options:#{} completionHandler:nil];
This is clipped from a project I did to do just that:
NSString *phoneStr = [NSString stringWithFormat:#"tel:%#",phone_number];
NSURL *phoneURL = [NSURL URLWithString:phoneStr];
[[UIApplication sharedApplication] openURL:phoneURL];
It may also be helpful to know how to prompt the user to call a number:
NSURL *phoneNumber = [NSURL URLWithString:#"telprompt://13232222222"];
[[UIApplication sharedApplication] openURL:phoneNumber];
telprompt gives the user a choice to place the call or cancel making the call before the phone dials. The two forward slashes after the colon are optional.
well if you are talking about using objective-c to make a phone call on the iphone, then you can do something like this:
NSURL *phoneNumber = [[NSURL alloc] initWithString: #"tel:867-5309"];
[[UIApplication sharedApplication] openURL: phoneNumber];
If you are talking about doing this on a mac ,well, then like others have mentioned that is specific based on number of things like, if you are using voip, a modem, connecting through something like an Asterisks box, etc..
openURL is deprecated.
Now use this:
UIApplication *application = [UIApplication sharedApplication];
[application openURL:[NSURL URLWithString: #"tel:12125551212"] options:#{} completionHandler:nil];
REMOVE EMPTY SPACES IN PHONE NUMBER
NSString *phoneNumberString = #"123 456";
phoneNumberString = [phoneNumberString stringByReplacingOccurrencesOfString:#" " withString:#""];
phoneNumberString = [NSString stringWithFormat#"tel:%#", phoneNumberString];
NSURL *phoneNumberURL = [NSURL URLWithString:phoneNumberString]];
[[UIApplication sharedApplication] openURL:phoneNumberURL];
NSString *phoneNumber = #"Phone number here";
UIWebView *webView = [[UIWebView alloc] init];
NSURL *url = [NSURL URLWithString:numberString];
NSURLRequest *requestURL = [NSURLRequest requestWithURL:url];
webView.dataDetectorTypes = UIDataDetectorTypeNone;
[webView loadRequest:requestURL];
This will either be very platform-specific, or you'll have to use a wrapper library to account for the differences among platforms, so you better state what platform this is intended for. In general, there are various telephony APIs available on most platforms.
On Windows systems there's for example the "TAPI", also things may somewhat differ if you are targeting a digital telephone system such as ISDN, because there are other APIs available.