Ios 在Google+上共享文本、图像和Url;未登录
我想在不登录iOS应用程序的情况下,在Google+上与Url共享图像 我使用了:Ios 在Google+上共享文本、图像和Url;未登录,ios,objective-c,sfsafariviewcontroller,qquickitem,nsurlcomponents,Ios,Objective C,Sfsafariviewcontroller,Qquickitem,Nsurlcomponents,我想在不登录iOS应用程序的情况下,在Google+上与Url共享图像 我使用了: NSString *temp = @"Hello World"; // Construct the Google+ share URL NSURLComponents* urlComponents = [[NSURLComponents alloc] initWithString:@"https://plu
NSString *temp = @"Hello World";
// Construct the Google+ share URL
NSURLComponents* urlComponents = [[NSURLComponents alloc] initWithString:@"https://plus.google.com/share"];
urlComponents.queryItems = @[[[NSURLQueryItem alloc]
initWithName:@"text"
value:temp]];
NSURL* url = [urlComponents URL];
if ([SFSafariViewController class]) {
// Open the URL in SFSafariViewController (iOS 9+)
SFSafariViewController* controller = [[SFSafariViewController alloc] initWithURL:url];
controller.delegate = self;
[self presentViewController:controller animated:YES completion:nil];
} else {
// Open the URL in the device's browser
[[UIApplication sharedApplication] openURL:url];
}
我不知道如何用同样的方法发送图像 回答这个问题可能太晚了,但有人会有用的
NSURL *shareURL = [NSURL URLWithString:@"https://example.com/image.jpg"];
urlComponents.queryItems = @[
[[NSURLQueryItem alloc] initWithName:@"url" value:[shareURL absoluteString]],
[[NSURLQueryItem alloc] initWithName:@"text" value:text]
];
回答这个问题可能太迟了,但有人会有用的
NSURL *shareURL = [NSURL URLWithString:@"https://example.com/image.jpg"];
urlComponents.queryItems = @[
[[NSURLQueryItem alloc] initWithName:@"url" value:[shareURL absoluteString]],
[[NSURLQueryItem alloc] initWithName:@"text" value:text]
];
Swift 4.1
let strKeyValue: String = "https://example.com/image.jpg"
guard var urlComponents = URLComponents(string: "https://plus.google.com/share") else {
return nil
}
urlComponents.queryItems = [URLQueryItem(name: "url", value:strKeyValue),URLQueryItem(name: "text", value:"This is testing text")]
let browserViewController = SFSafariViewController(url: urlComponents.url)
browserViewController.delegate = self
present(browserViewController, animated: true)
Swift 4.1
let strKeyValue: String = "https://example.com/image.jpg"
guard var urlComponents = URLComponents(string: "https://plus.google.com/share") else {
return nil
}
urlComponents.queryItems = [URLQueryItem(name: "url", value:strKeyValue),URLQueryItem(name: "text", value:"This is testing text")]
let browserViewController = SFSafariViewController(url: urlComponents.url)
browserViewController.delegate = self
present(browserViewController, animated: true)
我还面临着只共享url的问题,一旦它将我重定向到safari,它不会显示POST按钮,它会直接将我重定向到Google Plus页面。我还面临着只共享url的问题,一旦它将我重定向到safari,它不会显示POST按钮,它会直接将我重定向到Google Plus页面。谢谢你的回答!请格式化代码,使其显示为代码,确保每行至少缩进四个空格,这是最简单的方法?(我自己也看了一眼,不知道这些线到底是怎么包装的。)你能解释一下你为了制作这个Swift 4.1所做的修改吗?谢谢代码中没有太大的变化,但是语法肯定会有变化。谢谢你的回答!请格式化代码,使其显示为代码,确保每行至少缩进四个空格,这是最简单的方法?(我自己也看了一眼,不知道这些线到底是怎么包装的。)你能解释一下你为了制作这个Swift 4.1所做的修改吗?谢谢代码中没有太大的变化,但语法肯定有变化