I'm trying to format a URL string however it's saying there are too many arguments. My code is below:
-(IBAction)tweetRandom {
//NSLog(#"CALLED");
test = 100;
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"http://twitter.com/%i", test]]; // problem line
}
Anyone know how to format the URL? Was hoping there was something by the name of URLWithFormat but it doesn't exist.
You need to use stringWithFormat: like this:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"http://twitter.com/%i", test]]];
Related
I want to do the following. I have an array of objects (businesses) and each business has its own details including their telephone numbers.
I know how to make a call in Objective-C but I don't know how to update the numbers dynamically. I have a Details class (.h and .m) and I have declared tel as a variable.
So to make a call I would use below as an example
-(IBAction)MakePhoneCall:(id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:123456"]];
}
I use a DetailViewController so I have a list of businesses that gets populated and depending on the business selected, that business object is created. So for my tel I want to do the following:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel:" + detail.tel]];
But this obviously doesnt work. Can anyone please tell me how this is done?
if you're making a call from your application and you want the user back into the application after the end of the call then use telprompt: instead of tel: like below
-(IBAction)MakePhoneCall:(id)sender
{
NSURL *URL = [NSURL URLWithString:[NSString stringWithFormat:#"telprompt://%#",detail.tel]];
[[UIApplication sharedApplication] openURL:URL];
}
I would create a [NSString stringWithFormat], then plug that in the "URLWithString".
-(IBAction)MakePhoneCall:(id)sender
{
NSString *string = [NSString stringWithFormat:#"tel:%#", detail.tel];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:string];
}
Hope that helps.
here is the scenario:
I have fetched the iphone contact details into my application.And i have displayed email,phone details my View controller.
Now,I want to know how to invoke call event which i click on phone number in my application?
Well you just call the tel scheme:
NSURL *phoneURL = [NSURL URLWithString:#"tel:1234564897"];
BOOL hasPhone = [[UIApplication sharedApplication] canOpenURL:phoneURL];
if (hasPhone) {
[[UIApplication sharedApplication] openURL:phoneURL];
}
Apple URL scheme Reference
NSString *phoneNumber = #"tel://1234567890"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];
Try with
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:#"tel://123456789"]];
I Successfully Integrate Facebook in my App.Its also working fine on simulator and Iphone,With the dialog box.
But when i install facebook official App from Itunes in my Iphone.On share function it will take my App resources to that App.with the following pages.And when I delete Facebook Official App.Its again Works fine.
Any Solution???? Thanks in advance
Comment out the following lines of code of function
- (void)authorizeWithFBAppAuth:(BOOL)tryFBAppAuth safariAuth:(BOOL)trySafariAuth
in Facebook.m :
UIDevice *device = [UIDevice currentDevice];
if ([device respondsToSelector:#selector(isMultitaskingSupported)] && [device isMultitaskingSupported]) {
if (tryFBAppAuth) {
NSString *scheme = kFBAppAuthURLScheme;
if (_localAppId) {
scheme = [scheme stringByAppendingString:#"2"];
}
NSString *urlPrefix = [NSString stringWithFormat:#"%#://%#", scheme, kFBAppAuthURLPath];
NSString *fbAppUrl = [FBRequest serializeURL:urlPrefix params:params];
didOpenOtherApp = [[UIApplication sharedApplication] openURL:[NSURL URLWithString:fbAppUrl]];
}
if (trySafariAuth && !didOpenOtherApp) {
NSString *nextUrl = [self getOwnBaseUrl];
[params setValue:nextUrl forKey:#"redirect_uri"];
NSString *fbAppUrl = [FBRequest serializeURL:loginDialogURL params:params];
didOpenOtherApp = [[UIApplication sharedApplication] openURL:[NSURL URLWithString:fbAppUrl]];
}
}
This will always show a dialog box to the user.
I want to implement a contact us page where there are few phone numbers, and i want to call the number when the user clicks on them. So i decided to create buttons with the phone number as their title.
For the button click methods i have something like this
-(IBAction)numberClicked:(id)sender;
For initiation a call i know i can use this
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"tel:%#", phoneNumber]]];
My question is how should i modify the method so that it can take the phone number(title of te button) as argument.
Help would be appreciated.
Try
NSString *phoneNumber = [sender currentTitle];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"tel:%#", phoneNumber]]];
In my app i need a map to loaded by passing address,city, state province code and postal code.
Can any one tell me how can i do it??
You can use below :-
NSString* yourFullAddress = #"address,city, state province code and postal code";
yourFullAddress = [yourFullAddress stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
// Now create the URL string ...
NSString* urlString = [NSString stringWithFormat:#"http://maps.google.com/maps?q=%#", yourFullAddress];
// An the final magic ... openURL!
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlString]];
Or in case u dont want to open google maps and rather set the coordinates on ur MKMapView ... u can GeoCode ur address to get the coordinates and finally set the coordinate region on ur MKMapview ..
Did you even try searching on Google or SO?
A good start would be here http://blog.objectgraph.com/index.php/2009/04/02/iphone-sdk-30-playing-with-map-kit/