I am working on an app with links to external websites. I have been using code that opens safari separately, but I would like code that opens the website as a pop-over. Is this an option?
UIApplication.sharedApplication().openURL(NSURL(string:"http://www.bing.com")!)
You can use a UIWebView and load the url into it, you can add that to an existing view or create a view controller with a web view in it and present it as a popover.
let aWebView = UIWebView()
let myUrl = NSURL(string: "http://www.google.com")
let urlRequest = NSURLRequest(URL: myUrl!)
aWebView.loadRequest(urlRequest)
self.view.addSubview(aWebView)
Related
I'm using Webkit WKWebView to display locally stored HTML files in my OSX application for specific formatted pages.
Each of the WebView objects is linked to a WKWebview object in the storyboard of the application and is initialized using:
#IBOutlet var webView: WKWebView! = WKWebView()
I then display a local HTML using WebView:
let url = Bundle.main.url(forResource: "termsandconditions", withExtension: "html")
let urlRequest = NSURLRequest(url: url!)
outputView.load(urlRequest as URLRequest)
For each of the Webview Objects defined, XCode returns a warning
Could not signal service com.apple.WebKit.WebContent: 113: Could not find specified service
Am I initializing the WebViews correctly? Why is it trying to connect to the Apple service if I'm only using a local URL?
Determined that this is an Xcode issue making a call to the Apple. When compiled and running on a different device I cannot pick up the call being made.
I have an native iOS sample app installed in my iPad and also my sample xamarin.Forms App installed. I want to open native iOS app from Xamarin.forms when clicked on button. I have set URL schema in my native iOS app in info.plist.
How do I open native app from xamarin.forms on click of a button. I already tried
var request = Device.OnPlatform(
string.Format("native app url"),
string.Format("native app url"),
string.Format("native app url"));
Device.OpenUri(new Uri(request));
but its not working.
It's basically how you are doing it.
var url = Device.OnPlatform(iOSUrl, androidUrl, winPhoneUrl);
Device.OpenUri(new Uri(request));
Be aware that each platform have some requirements in the way to url is configured and parameters are sent.
Let say to get the maps app open in each platform you would use these urls schemes:
// iOS doesn't like %s or spaces in their URLs, so manually replace spaces with +s
var iOSUrl = string.Format("http://maps.apple.com/maps?q={0}&sll={1}", name.Replace(' ', '+'), loc);
var androidUrl = string.Format("geo:0,0?q={0}({1})", string.IsNullOrWhiteSpace(addr) ? loc : addr, name);
var winPhoneUrl = $"bingmaps:?cp={loc}&q={name}";
var url = Device.OnPlatform(iOSUrl, androidUrl, winPhoneUrl);
Also you cannot open any arbitrary app unless you know its Url scheme.
Anyway, if the Device.OpenUri() doesn't fulfill your requirements you are good to create your own implementations using the native APIs.
Please go through the below link and attached photo
Link:-launch-an-app-from-within-another-iphone
I am using below code in xamarin forms
NSUrl request = new NSUrl("Camera://");
var canOpen = UIApplication.SharedApplication.CanOpenUrl(new NSUrl(request.ToString()));
if (!canOpen)
{ Task.FromResult(false); }
else
{
Task.FromResult(UIApplication.SharedApplication.OpenUrl(new NSUrl(request.ToString())));
}
I'm trying to share a photo using FBSDKSharePhotoContent and make the applink works but I bang my head to make it works.
My app is mobile only so the photos are not hosted on any web site.
I use this code to share the photo:
let photo = FBSDKSharePhoto()
photo.image = currentHeaderImage
photo.userGenerated = false
let photoContent = FBSDKSharePhotoContent()
photoContent.photos = [photo]
photoContent.hashtag = FBSDKHashtag(string: "#Showflix")
photoContent.contentURL = NSURL(string: "applink...")
FBSDKShareDialog.showFromViewController(self, withContent: photoContent, delegate: nil)
I generated the applink using the Facebook Developer site interface.
The photo is corretly published on Facebook but there are no link in the post. If I click on the photo it only open a normal photo on facebook.
I tried also using photo.imageUrl, I tried also FBSDKShareDialog without success.
All I need is to share a photo on Facebook user wall and if someone clicks on this photo it should propose to open it in the mobile app.
Thanks for help
I am a .Net Developer and just started my first iOS project using swift. I want to navigate from one view controller to another using code. Like we do in WP 8.1 with the help of following code:
Frame.Navigate(Typeof("Page_2"));
Another way that you can do it depending on how you are calling or executing the code.
self.performSegueWithIdentifier("YourSegueIdentifier", sender: self)
Give your destination view controller an identifier (in storyboard). Then, put this into the view controller you're navigating from...
let controller = self.sender.storyboard?.instantiateViewControllerWithIdentifier("resultController") as! ResultController
controller.myViewModel= myViewModel!
self.sender.navigationController?.pushViewController(controller, animated: true)
I am developing a COCOA application. It's a requirement of the application to load HTML page from a local directory. The HTML page includes links to many resources such as images, JavaScript, XML and CSS file. Hence it's more like a local website without any server. How can I achieve this using WebView control? I am developing application for Mac OS X.
Any help would be highly appreciated,
Farooq-
You can simply use this code -
[[yourWebView mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:pathOfLocalWebPage]]];
Hope this helps :)
Swift 3:
let urlpath = Bundle.main.path(forResource: "index", ofType: "html");
let requesturl = URL(string: urlpath!)
let request = URLRequest(url: requesturl!)
webView.mainFrame.load(request)