I'm stuck with a navigation issue while using a GPX file to create a route navigation (turn by turn)
My GPX file parsing seems to work since I've managed to build a CLLocation Array.
The problem is that nothing shows up on my Map view. I have no routing delegate callback neither ( with the event :didFinishRouteCalculationWithInfo)
Here is my code :
let path: String = NSBundle.mainBundle().pathForResource(fileName, ofType: "gpx")!
do {
let root: SKGPSFileElement = try SKGPSFilesService.sharedInstance().loadFileAtPath(path)
let locationArray = SKGPSFilesService.sharedInstance().locationsForElement(root)
let route = SKRouteSettings()
route.shouldBeRendered = true
route.requestAdvices = true
SKRoutingService.sharedInstance().calculateRouteWithSettings(route, customLocations: locationArray)
// I also tried to read directly my SKGPSFileElement :
//SKRoutingService.sharedInstance().calculateRouteWithSettings(route, GPSFileElement: root)
} catch {
}
I tried to get some help with the Swift Skobbler Demo but they also have the issue ... (When selecting the Berlin GPX track for instance, no track appears)
Thank you in advance, I'm desperate :'( !
Okay, once again the demo project missed some lines ...
I only had to add these lines to make it work :
SKRoutingService.sharedInstance().navigationDelegate = self
SKRoutingService.sharedInstance().routingDelegate = self
SKRoutingService.sharedInstance().mapView = map
Hope it could help someone :)
Related
i am trying to add facebook share dialog into my ios application and i found the official page from facebook on how to do it, but i run into a problem about ContentProtocol. i dont know what that is. here is the link to the guidence that i use . it is pretty straight forward. basically just install the pod facebookshare, import it and add few line of code, but i got problem on 'myContent'
here is the code
import FacebookShare
let shareDialog = ShareDialog(content: myContent)
shareDialog.mode = .Native
shareDialog.failsOnInvalidData = true
shareDialog.completion = { result in
// Handle share results
}
try shareDialog.show()
here is the link
https://developers.facebook.com/docs/swift/sharing/share-dialog
what should i put in the myContent?
I guess next link is explained what you can use as content and how to use it
Content-types
(From documentation) Currently, the Facebook SDK for Swift can share 4 different kinds of content:
Links - Represented by the LinkShareContent object.
Photos - Represented by the PhotoShareContent object.
Videos - Represented by the VideoShareContent object.
Open Graph - Represented by the OpenGraphShareContent object.
you can use FBSDKShareLinkContent
let content : FBSDKShareLinkContent = FBSDKShareLinkContent()
content.contentURL = NSURL(string: "//URL")
content.contentTitle = "MyApp"
content.contentDescription = "//Desc"
content.imageURL = NSURL(string:"//Image URL")
I want to create xul based frame in one of my firefox extension. The frame should look like https://developer.mozilla.org/en-US/Add-ons/SDK/Low-Level_APIs/ui_frame
or
how to use below node js code in xul:
var { Frame } = require("sdk/ui/frame");
var frame = new Frame({
url: "./city-info.html"
});
In node.js, its working fine, but I dont know how to create the same thing with xul. Anybody can help?
thanks in advance.
You have provided very little detail as to what you desire. If all that you desire is to create an <iframe> in which you can load HTML content, then something along the lines of the following will do so:
//The URL of the HTML you desire to load.
let chromeUrl = '[Some URL here]';
//Whatever element you want the iframe placed under.
let parentEl = document.getElementById('foo');
//* Overlay and bootstrap (from almost any context/scope):
Components.utils.import('resource://gre/modules/Services.jsm');//Services
let activeWindow = Services.wm.getMostRecentWindow('navigator:browser');
//*/
let mainDocument = activeWindow.document;
//Create the <iframe> use
//mainDocument for the XUL namespace.
let iframeEl;
if(options.useBrowser){
iframeEl = mainDocument.createElement('browser');
} else {
iframeEl = mainDocument.createElement('iframe');
}
iframeEl.id = id;
iframeEl.setAttribute('src',chromeUrl);
iframeEl.setAttribute("tooltip", "aHTMLTooltip");
iframeEl.setAttribute("autocompleteenabled", true);
iframeEl.setAttribute("autocompletepopup", "PopupAutoComplete");
iframeEl.setAttribute("disablehistory",true);
iframeEl.setAttribute('type', 'content');
parentEl.appendChild(iframeEl);
The above code was taken from my answer to Firefox SDK Add-on with a sidebar on both the right and left at the same time, which creates sidebars. One option of how those sidebars are created is to have them contain an <iframe>.
Finally I got the answer:
let chromeUrl = 'YOUR HTML PAGE URL';
Components.utils.import('resource://gre/modules/Services.jsm');//Services
let activeWindow = Services.wm.getMostRecentWindow('navigator:browser');
//*/
let mainDocument = activeWindow.document;
let iframeEl;
iframeEl = mainDocument.createElement('iframe');
iframeEl.id = "d";
iframeEl.setAttribute('src',chromeUrl);
iframeEl.setAttribute("tooltip", "aHTMLTooltip");
iframeEl.setAttribute("autocompleteenabled", true);
iframeEl.setAttribute("autocompletepopup", "PopupAutoComplete");
iframeEl.setAttribute("disablehistory",true);
iframeEl.setAttribute('type', 'content');
iframeEl.setAttribute('height', '32px');
window.document.documentElement.appendChild(iframeEl);
I am having some issues to get MBProgressHUDModeDeterminateHorizontalBar style to work
Haven't found much around on Swift.
I've tried so far to create an object passing the MBProgressHUDModeDeterminateHorizontalBar as type or attribute it as a mode to an existing HUB object or add an int to the mode... but nothing seems to work.
let spinningActivity = MBProgressHUD.showHUDAddedTo(self.view, animated: true)
spinningActivity.labelText = "Loading"
spinningActivity.detailsLabelText = "Please got get some coffee"
You need to change MBProgressHUD mode. See code bellow.
spinningActivity.mode = .DeterminateHorizontalBar
And update your loading progress:
spinningActivity.progress = /*Your loading progress*/
Hope that help!
I have the following code and is working for me but it can only currently show artist and song :
let mpic = MPNowPlayingInfoCenter.defaultCenter()
mpic.nowPlayingInfo = [MPMediaItemPropertyTitle:songs[currentAudioIndex].songName,
MPMediaItemPropertyArtist:songs[currentAudioIndex].artistName]
I tried also setting the picture with the following code but it isn't working :
mpic.nowPlayingInfo = [MPMediaItemPropertyTitle:songs[currentAudioIndex].songName,
MPMediaItemPropertyArtist:songs[currentAudioIndex].artistName,
MPMediaItemPropertyArtwork:songs[currentAudioIndex].songImage]
SongImage is of type UIImage.
Never mind I figured out.
If anyone want to learn you have to
do the following
let mpic = MPNowPlayingInfoCenter.defaultCenter()
// initialize an instance of MPMediaItemArtWork with a UIImage
var albumArtWork = MPMediaItemArtwork(image: songs[currentAudioIndex].songImage)
// Then assign it to the MPNowPlayingInfoCenter
mpic.nowPlayingInfo = [
MPMediaItemPropertyTitle:songs[currentAudioIndex].songName,
MPMediaItemPropertyArtist:songs[currentAudioIndex].artistName,
MPMediaItemPropertyArtwork:albumArtWork
]
Hope this helps anyone who is also struggling with this.
Thanks
MPNowPlayingInfoCenter.defaultCenter().nowPlayingInfo = [MPMediaItemPropertyArtist : AudioCenter.sharedInstnce.currentReciter().name,
MPMediaItemPropertyTitle : AudioCenter.sharedInstnce.currentSurah()!.name,
MPMediaItemPropertyArtwork:MPMediaItemArtwork(image: UIImage(named: "Logo")!)]
I've been working in Titanium appaccelerator and now I'm trying to open a video in it.
I've used the following code:
movieWindow.js
function displayVideo()
{
var window = Ti.UI.createWindow({
width:200,
height:300,
});
var activeMovie = Titanium.Media.createVideoPlayer({
url:"respigrandsoupir.mp4",
width:300,
height:200,
top:50,
left:50,
backgroundColor:'#0f0'
});
window.add(activeMovie);
activeMovie.play();
return window;
}
My video respigrandsoupir.mp4 is under the Resource folder. The problem is that when trying to run this method I get the following error:
[WARN] Exception in event callback. { expressionBeginOffset = 159;
expressionCaretOffset = 173;
expressionEndOffset = 191;
line = 12;
message = "Result of expression 'Titanium.Media' [undefined] is not an object.";
name = TypeError;
sourceId = 238167336;
sourceURL = "file://localhost/Users/adrian/Documents/Titanium%20Studio%20Workspace/La%20Pause/Resources/movieWindow.js";
}
Can one tell me where am I going wrong?
Thank you for your valuable answers, but Project->Clean solved my issue!
When you use a new object like Titanium.Media that you never used before, a clean is often required because Titanium builds a custom light version in the target folder.
If you don't clean, it will search in vain the widget in this folder.