On IOS, I am using the following to launch a video URI in a browser. Works great:
NSURL *urlVideo = [NSURL URLWithString: #"http://www.youtube.com/watch?v=jIxC22Pp1ZI&feature=player_embedded"];
[[UIApplication sharedApplication] openURL: urlVideo];
How do I do the similar action, but launch a video App instead. In Android, I will get a Chooser Dialog if I construct the URI correctly. Eventually, I will have to implement on both platforms, so I want to be architecturally the same.
You can use url scheme methods of UIApplication objects. The proper method should be openURL i believe.
Here is the reference: http://developer.apple.com/library/ios/#featuredarticles/iPhoneURLScheme_Reference/Introduction/Introduction.html
If you want to play the video using youtube, you can do it like this :
NSURL *urlVideo = [NSURL URLWithString: #"http://www.youtube.com/watch?v=jIxC22Pp1ZI"];
[[UIApplication sharedApplication] openURL:myURL];
// the last parameter 'jIxC22Pp1ZI' is the video identifier .
If you want to launch some other video player, you have to know the custom URL scheme, and pass that to the openURL method.
Related
I'm using this library for my Xamarin.Forms app: https://github.com/Redth/ZXing.Net.Mobile
Just to start off, it's working perfectly on Android. iOS shows the camera viewfinder, but it doesn't ever recognize any barcodes.
I initialize it in my AppDelegate as required:
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init();
ZXing.Net.Mobile.Forms.iOS.Platform.Init();
LoadApplication(new App(new iOSInitializer()));
return base.FinishedLaunching(app, options);
}
I also set the permission description in Info.plist:
<key>NSCameraUsageDescription</key>
<string>Please allow access to the camera to scan barcodes</string>
But I guess that's obvious, or else the camera viewfinder wouldn't work either.
I got some issues with Zxing in my app too, but i noticed that some problems are solved with the right version in both Android and IOS, i'm currently using the version 2.3.1 (not 2.4.1) and works perfect, besides, i realized that you should not use your ZxingPage first at the stack, that is why i always put a page before to avoid any crash:
var root = Application.Current.MainPage.Navigation.NavigationStack[0];
Application.Current.MainPage.Navigation.InsertPageBefore(new View(), root);
And then i call the ZxingPage. Hope it helps :)
I want to set my UIImage to WKInterfaceImage, but the simulator shows only black screen.
It works OK using setImageNamed: NSString* method, but not with setImage: UIImage* . My file1.png is added to "(App Name) WatchKit App" folder.
- (void)willActivate {
[self.imageView1 setImage: [UIImage imageNamed: #"file1"]]; // doesn't work
[self.imageView1 setImageNamed: #"file1"]; // works OK
[super willActivate];
}
Thanks!
Everything is working as expected.
file1 is in your WatchKit App folder, which means it is on the watch.
Calling [UIImage imageNamed:] loads from the main bundle, which doesn't contain file1, so you get nil.
The way you are doing this is correct. setImageNamed: will look for images on the Watch first, then in the cache.
Calling [UIImage imageNamed:imageName] from your extension will always return nil for a cached image. The image is cached on the watch — not in your extension.
Once an image is cached, it allows you to set a WKInterfaceImage using the [WKInterfaceImage setImageNamed:] method.
I have an iOS 6 app that I am updating to work with iOS 7 and to make it use storyboards. I am trying to use multiple storyboards so that I can break my project down into modules for each screen in the app. So far this has worked out fine but now I need to provide a way to navigate between the various storyboards while still making the work like it did in iOS 6 (but with updated artwork).
I don't use UINavigationController in my existing iOS 6 app and I would prefer not to use it as up to now I have been able to navigate back and forth between XIB's using code on UIButton tap gestures. The UINavigationController doesn't make it easy to customise how the navigation buttons look from what I have learned so far about it.
I found this very clean way of moving between view controllers that are on different storyboards https://github.com/rob-brown/RBStoryboardLink by passing the name of the storyboard in as an attribute.
But it only seems to work when UINavigationController is used. I get an error "Push segues can only be used when the source controller is managed by an instance of UINavigationController" without UINavigationController.
Is there a way to navigate between storyboards by only using the above RBStoryboardlink but without the need for UINavigationController?
Push segues can only be used when the source controller is managed by an instance of UINavigationController
This means you are trying to push a view controller to the source while source don't have any navigation controller stack.In that case, you should try to add the instantiated view controller's view as subview to the source view controller's view.
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
UIViewController *viewController = [mainStoryboard instantiateInitialViewController];
[self.view addSubview:viewController.view];
or you modally present, that purely depends on your requirement.
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
UIViewController *viewController = [mainStoryboard instantiateInitialViewController];
tabBarViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:tabBarViewController animated:NO completion:NULL];
I have a desktop AIR app built with Flex 4.6 and Air 3.5. I use navigateToURL to launch a URL in the default browser, works fine:
var request : URLRequest = new URLRequest ( "http://localhost:8890/test.html" );
var urlVariables : URLVariables = new URLVariables ();
urlVariables['activity'] = "xyz.json";
request.data = urlVariables;
request.method = URLRequestMethod.GET;
navigateToURL(request, "_self");
The app lets the user construct some JSON content (xyz.json), then test it in a test rig (test.html).
The second and subsequent times I do this, I get a new tab (I'm using Chrome). What I want is for it to appear in the same tab as the last one. Note that I've used "_self". If I pass any string I get the same result.
Any help would be appreciated. Thanks.
I dont believe it is possible to force browser to reuse same tab - that would be browser behaviour, not AIR behaviour (ie: you would change the expected behaviour in browser settings; eg: always open content in new tab).
I believe from a desktop app when you invoke NavigateToURL() it will force a new window (container) to launch.
If you can you could create a separate 'receiver' page on the server to receive the data (invisible to the user) Then launch a 'viewer' page with NavigateToURL that would contain an ajax script to check and update the data received from the 'receiver' page.
I would check out URLLoader() Class. I use this many times for my web service scripts.
I am attempting to follow this example: http://howtomakeiphoneapps.com/uiwebview-tutorial/239/
I have added a UIWebView into my view (using Storyboard)... I added the IBOutlet to my .h controller file. (see image at: http://imgur.com/GfUmC). I added a delegate to the view controller like this:
#import <UIKit/UIKit.h>
#interface slWebViewController : UIViewController <UIWebViewDelegate> {
IBOutlet UIWebView *slWebView;
}
#end
Since I'm using XCode 4, I don't know how to set the UIWebView's delegate to the File Owner, which is why I think this is what I'm getting a black screen. I'm missing something, but I don't know what. At this point, I would really, really appreciate any help I can get solving this...
In your Storyboard, right click (or ctrl-click) and drag from your UIWebView to the File's Owner on the left side, and choose "delegate".
Alternatively, select the webView (as in your image). Note the top outlet, "delegate". Drag from there to the File's Owner.
Or you can code it. In viewDidLoad, type "self.sIWebView.delegate = self;"
All of this is assuming that you have your URL request right. In case you don't, here's an example:
NSURL * url = [NSURL URLWithString:#"http://google.com"];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: url
cachePolicy: NSURLRequestReloadIgnoringCacheData
timeoutInterval: 10];
[sIWebView loadRequest:request];
EDIT: If you are presenting the webView modally, add this code to the view controller that segues to your webview: -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ if ([segue.identifier isEqualToString:#"SegueIdentifier"]) { WebViewController *webView = segue.destinationViewController; webView.delegate = self; } } You'll need to add an identifier to your segue. Just click on the segue itself, go to the third tab from the right, and type in an identifier.
UPDATE: I've isolated the problem to the webViewConroller.m file. Everything is connected properly. If I place the loadRequest code in the viewController at viewDidLoad, I see Google. If I place the loadRequest code in the "webViewController", and mark the ViewContoller as a custom class of webViewController, I get the black screen. I'm wondering if there isn't a better way to get the UIWebView to display content? I really don't need a controller for the webView, just when the segue for that cell is tapped, display the contents of the UIWebView... not sure I can do it with XCode...