How to play a video splash in ios?(Objective c) - objective-c

I need a help in how to implement the video splash while my application launches in ios.
The sample which is similar to:
http://www.iosappx.com/code/9173/

It's really simple guy.
You can find the solution in sample project here :
https://github.com/chinsyo/uber-video-welcome
You can make a fake splash screen and load it after the original Splash appeared with smoothly animation then you play the video as you want
Bests,

You could have a "fake" launch video. So, if you have a local video file(mp4 or other supported formats), you could set the window rootViewController to AVPlayerViewController. Example as below:
Within your AppDelegate.m file,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
AVPlayer *player = [AVPlayer playerWithURL:"YOUR URL"];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(continueWithLaunch) name: AVPlayerItemDidPlayToEndTimeNotification object:player];
// create a player view controller
AVPlayerViewController *controller = [[AVPlayerViewController alloc] init];
self.window.rootViewController = controller;
controller.player = player;
[player play];
}
-(void) continueWithLaunch {
//Change the window rootView controller to your base controller (e.g. tabbar controller)
}

I don't think it is possible: right now, the only "splash" (i.e., launch) screens you can implement for iOS are either:
Static images (the historic Default*.png)
Single-page storyboards (Launchscreen.storyboard)
The app you linked to seems to be just playing video on its first (login) screen, after the "splash" (likely, backed by a view controller).

Related

Local Notification To Load a View

I have an app that using local notifications, I want to have the app load a different page when a notification is recived. I also want it to load this new view when the slide to unlock over the notification is used.
My storyboards do not have a navigation controller is this possible to be done?
You can handle local notifications in the following ways:
Add in following method located in AppDelegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
This code:
// Handle launching from a notification
UILocalNotification *locationNotification = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (locationNotification) {
// Set icon badge number to zero
application.applicationIconBadgeNumber = 0;
// redirect to UIViewController
UIStoryboard * storyBoard = [UIStoryboard storyboardWithName:#"Storyboard" bundle:[NSBundle mainBundle]];
UIViewController * notificationViewController = [storyBoard instantiateViewControllerWithIdentifier:#"IdentifierOfViewController"];
self.window.rootViewController = notificationViewController; // set the new UIViewController
}
This allows you to handle LOCAL notifications as soon as the app is launched, either by acting on a 'slide to view' dialog or just by opening the app.
You can then change the rootViewController in the application if there is a notification
My storyboards do not have a navigation controller is this possible to
be done?
Yes, this wouldn't be a problem as long you use modal navigation.
EDIT
If you want to handle the notifications if the app is currently opened by the user you can catch the notification, by placing the following method in the AppDelegate:
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification

Three20: Photo Viewer customization

I need a gallery in my application and I found this tutorial on how to implement the Three20 into my application: http://www.raywenderlich.com/1430/how-to-use-the-three20-photo-viewer.
I've a storyboard where the root is a Tab Bar Controller. This root controller has a relation with a View Controller with the class PhotoViewController from the above tutorial.
The last step in the tutorial is to add code to the AppDelegate, but in my case I added this code to the PhotoViewController:
#import "PhotoViewController.h"
#import "PhotoSet.h"
#implementation PhotoViewController
#synthesize photoSet = _photoSet;
- (void) viewDidLoad {
[[TTURLRequestQueue mainQueue] setMaxContentLength:0];
TTNavigator *navigator = [TTNavigator navigator];
UIWindow *window = [UIApplication sharedApplication].keyWindow;
navigator.window = window;
TTURLMap *map = navigator.URLMap;
[map from:#"tt://appPhotos" toSharedViewController:[PhotoViewController class]];
[navigator openURLAction:[TTURLAction actionWithURLPath:#"tt://appPhotos"]];
self.photoSource = [PhotoSet samplePhotoSet];
}
- (void) dealloc {
self.photoSet = nil;
}
#end
Here is a image of the result after tabbing the "Gallery" tab in the root tab controller:
Here is a image when I scroll in the view:
This is almost fine, but I have some issues:
When I tab the Gallery and the above view appear, there is no way back to the root tab controller. How can I add a back button?
When I swipe in the gallery, the text "Error" is displayed for a while until the image is fully loaded. Why?
When I tab "See All" it shows an list of all images. How can I change the background-color for the navigation bar in the top?
I think that MWPhotoBrowser has a nicer interface than EGOPhotoViewer (feels closer to the native Photos app).
MWPhotoBrowser is an implementation of a photo browser similar to the native Photos app in iOS. It can display one or more images by providing either UIImage objects, file paths to images on the device, or URLs to images online. The photo browser handles the downloading and caching of photos from the web seamlessly. Photos can be zoomed and panned, and optional (customisable) captions can be displayed. Works on iOS 3.2+. All strings are localisable so they can be used in apps that support multiple languages.
Better try EGOPhotoViewer.

Draggable/tabbable UIPopOverController?

I don't know if you people are familiar with the Blackboard Learn app for iPad. Well it has PopUp windows to show info.
Well, I would like to implement something similar on a iPad app, and I was wondering if it is possible to doit with UIPopOverControllers...
Basically you can open a view and drag it around and keep it on a border of the screen as a tab to show updates and so.
Is it possible to do something similar with UIPopOverControllers or UIViews (the dragging and the tabbing)?
Cheers from Mexico
UPDATE 1:
Well, I managed to load multiple UIViews, next thing goes to be able to drag 'em around, any suggestions?
UPDATE 2:
I tried to add the UIPanGestureRecognizer in otherView.m (the Pop Up Window), here's how it looks
otherView.h
#interface otherView : UIViewController <UIGestureRecognizerDelegate>{
UIPanGestureRecognizer *drag;
}
#property (nonatomic, retain) UIPanGestureRecognizer *drag;
...
otherView.m
- (void)viewDidLoad {
[super viewDidLoad];
// Drag
drag = [[UIPanGestureRecognizer alloc]
initWithTarget:self action:#selector(dragAction)];
[self.view addGestureRecognizer:drag];
[drag release];
}
otherView is displayed in mainWindow directly from the appDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after app launch.
// Set the view controller as the window's root view controller and display.
//self.window.rootViewController = self.viewController;
[window addSubview:viewController.view];
[window addSubview:secondView.view];
[self.window makeKeyAndVisible];
return YES;
}
Hope you can help me out
As far as I know there is no mechanism to move a popover around on the screen - they are attached to a bar button or point in a view and that is where they exist until they are dismissed. Popovers also don't allow interaction with views (buttons, text fields etc) in the main view while they are visible.
Sounds like a great user interface concept though, good luck!!

iPad SplitView Application not taking up entire window

I am working on a split-view based application for the iPad. I created a menu overlay system that has a button that leads into the split-view application. See comment for image
When you click the enter button, however, it results in this:
http://commandoswat.webs.com/Screen%20shot%202010-09-16%20at%201.37.11%20PM.png
Here is my code for the application delegate:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after app launch.
mainMenuController = [[MainMenuController alloc]init];
mainMenuController.sWindow = window;
mainMenuController.sController = splitViewController;
// Add the split view controller's view to the window and display.
[window addSubview:mainMenuController.view];
[window makeKeyAndVisible];
return YES;
}
Here is my code for the MainMenuController Enter Button:
-(IBAction) enterButton{
[self.view removeFromSuperview];
[sWindow addSubview:sController.view];
}
How do I make the split view take up the entire screen?
Any suggestions?
Thanks
Looks to me that your detail view isn't sized properly, and/or doesn't have its autoresizingMask property set appropriately (to have flexible width).

How can I display a splash screen for longer on an iPhone?

How can I display a splash screen for a longer period of time than the default time on an iPhone?
Read the Apple iPhone Human Interface Guidelines (HIG). The "splash screen" isn't supposed to be for branding or displaying a logo, it's supposed to look like the default condition of the app so it appears to start up quickly.
Making it stay there for longer would be a violation of the HIG.
The simplest way to do this is to create a UIImageView who's image is your Default.png. In your applicationDidFinishLaunching: method, add that image view to your window, and hide it when you'd like your splash screen to go away.
I needed to do this to block showing a table view until the data was loaded over the network. I used a variation of one I found here:
http://michael.burford.net/2008/11/fading-defaultpng-when-iphone-app.html
In the interface of your App Delegate:
#interface AppDelegate : NSObject
{
UIImageView *splashView;
}
In the implementation:
#implementation AppDelegate
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// After this line: [window addSubview:tabBarController.view];
splashView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
splashView.image = [UIImage imageNamed:#"Default.png"];
[window addSubview:splashView];
[window bringSubviewToFront:splashView];
// Do your time consuming setup
[splashView removeFromSuperview];
[splashView release];
}
Make sure you have a Default.png in the resources
in your appDelegate , theres a method called applicationDidFinishedLaunching use a sleep function. Pass a digit in the sleep function for the no. of seconds you want to hold screen.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[window makeKeyAndVisible];
[window addSubview:viewController.view];
sleep(5);
return YES;
}
I searched so much for this thing and everybody gave their own complex point of view. I couldn't find a simple way that would just let me do it.
KISS ( Keep it simple and Smart :)
I avoided the actual as its offensive.
Even though it is against the guidelines but if you still want to do this than a better approach rather than sleeping thread will be
//Extend the splash screen for 3 seconds.
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:3]];
this way the main thread is not blocked and if it is listening for any notifications and some other network related stuff, it still carries on.
UPDATE FOR SWIFT:
NSRunLoop.currentRunLoop().runUntilDate(NSDate(timeIntervalSinceNow:3))
I did it pretty simply, by having my rootViewController push a modalViewController, loading from "Splash.nib" in a subclass of UIViewController I called "SplashViewController". The exact call was:
- (void) viewDidLoad {
SplashViewController *splashScreen = [[[SplashViewController alloc]
initWithNibName:#"SplashViewController" bundle:nil] autorelease];
[self presentModalViewController:splashScreen animated:NO];
//continue loading while MVC is over top...
When you launch the app, it pops right up, like a splash screen should. Then, the SplashViewController nib is just a full-screen UIImageView with a splash png, 320x480. After a 1-second NSTimer (anything more did seem to get in the way), it fires timerFireMethod, a custom method that just calls
[self dismissModalViewControllerAnimated:YES];
Then the modal VC just slides down and away, leaving my top tableView. The nice thing is, while the MVC is up, the underlying table can continue to load due to the independent nature of modal view controllers. So, I don't think this violates the HIGs, and actually does allow for faster launching. What would you rather look at, a cute picture, or an empty default view (snore)?
Yes, the simplest way is (remember to add your 'default.png' to targets -> [yourProjectName]: launch images in 'xCode'):
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[NSThread sleepForTimeInterval:3.0];
}
Make your app take longer to load.
In all seriousness, Paul Tomblin is correct that this usually isn't a good idea. Default.png is a mechanism intended to make your app appear to load faster by holding an "empty" screenshot. Using it for a splash screen is a minor abuse, but intentionally making that splash screen appear for longer than it needs to is almost sick. (It will also degrade your user experience. Remember, every second the splash screen is visible is a second that the user is impatiently staring at your logo, swearing they'll switch to the first decent competitor they can find.)
If you're trying to cover for some sort of secondary loading--for example, if the interface has loaded and you're just waiting to get some data from the network--then it's probably okay, and Ben Gottlieb's approach is fine. I'd suggest adding a progress bar or spinner to make it clear to the user that something really is going on.
simply use sleep(time in seconds); in your applicationDidFinishedLaunching method
Here is my simple splash screen code. 'splashView' is an outlet for a view
that contains an image logo, UIActivityIndicator, and a "Load.." label (added
to my 'MainWIndow.xib' in IB). The activity indicator is set to 'animating' in IB,
I then spawn a separate thread to load the data. When done, I remove the
splashView and add my normal application view:
-(void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:splashView];
[NSThread detachNewThreadSelector:#selector(getInitialData:)
toTarget:self withObject:nil];
}
-(void)getInitialData:(id)obj {
[NSThread sleepForTimeInterval:3.0]; // simulate waiting for server response
[splashView removeFromSuperview];
[window addSubview:tabBarController.view];
}
Inside your AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Sleep is code to stop the slash screen for 5MoreSeconds
sleep(5);
[self initializeStoryBoardBasedOnScreenSize];
return YES;
}
//VKJ
In Xcode 6.3, you can show the launch screen.xib and even put a indicator on it, first it will show the default launch screen it is replaced by the nib so the user doesn't know it changed and then if everything is loaded hide it :-)
func showLaunchScreen() {
// show launchscreen
launchView = NSBundle.mainBundle().loadNibNamed("LaunchScreen", owner: self, options: nil)[0] as! UIView
launchView.frame = self.view.bounds;
self.view.addSubview(launchView)
// show indicator
launchScreenIndicator = UIActivityIndicatorView(frame: CGRectMake(0, 0, 50, 50)) as UIActivityIndicatorView
launchScreenIndicator.center = CGPointMake(self.view.center.x, self.view.center.y+100)
launchScreenIndicator.hidesWhenStopped = true
launchScreenIndicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyle.Gray
launchView.addSubview(launchScreenIndicator)
self.view.addSubview(launchView)
launchScreenIndicator.startAnimating()
self.navigationController?.setNavigationBarHidden(self.navigationController?.navigationBarHidden == false, animated: true) //or animated: false
}
func removeLaunchScreen() {
println("remove launchscreen")
self.launchView.removeFromSuperview()
self.launchScreenIndicator.stopAnimating()
self.navigationController?.setNavigationBarHidden(false, animated: true)
}
Write an actual splash screen class.
Here's a freely usable splash screen that I recently posted in my iPhone in Action blog:
http://iphoneinaction.manning.com/iphone_in_action/2009/03/creating-a-splash-screen-part-one.html
The simplest way is to put your application's main thread into a sleep mode for desired period of time. Provided that "Default.png" exists in your application's bundle it will be displayed for as long as the main thread is asleep:
-(void)applicationDidFinishLaunching:(UIApplication *)application {
[NSThread sleepForTimeInterval:5];
window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
[window setBackgroundColor:[UIColor yellowColor]];
[window makeKeyAndVisible];
}
As you are already aware, it's a horribly bad idea to do but it should work just fine...
just make the window sleep for some seconds in applicationDidFininshLaunchings method
example: sleep(3)
According to the Apple HIG you should not do that. But if your application needs to do so for definite purpose, you can do:
import <unistd.h> in your AppDelegate.m
Write the following line at the first of the "application didFinishLaunchingWithOptions:" method
sleep(//your time in sec goes here//);
I have done this as below:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"LaunchScreen" bundle:nil];
UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:#"splashView"];
self.window.rootViewController = viewController;
Note: LaunchScreen is the launch story borad and splashView is the storyboardIdentifier
For stylish splash screen tutorial check out this
http://adeem.me/blog/2009/06/22/creating-splash-screen-tutorial-for-iphone/
I agree it can make sense to have a splash screen when an app starts - especially if it needs to get some data from a web site first.
As far as following Apple HIG - take a look at the (MobileMe) iDisk app; until you register your member details the app shows a typical uitableview Default.png before very quickly showing a fullscreen view.
What I did is presented a modalview controller in the initial screen and then dissmiss it after several seconds
- (void)viewDidLoad
{
[super viewDidLoad];
....
saSplash = [storyboard instantiateViewControllerWithIdentifier:#"SASplashViewController"];
saSplash.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentModalViewController: saSplash animated:NO];
}
-(void) dismissSASplash {
[saSplash dismissModalViewControllerAnimated:NO];
}
There are many options already posted here, but I ran into cocoapod today that allows you to display the contents of your LaunchScreen.xib as the initial view controller:
https://github.com/granoff/LaunchScreen (Also see this blog post from the author with more implementation details.)
This seems like a fairly straight-forward way to do this, and better than the vast majority of answers posted here. (Of course it wasn't possible until the introduction of LaunchScreen files in the first place.) It is possible to display an activity indicator (or anything else you want) on top of the view.
As for why you would want to do this, I'm surprised that no one has mentioned that there are often publisher and/or partner requirements around this sort of thing. It's VERY common in games, but advertising-funded applications as well.
Also note that this does act counter to the HIG, but then so does waiting to load any content after your application launches. Remember that the HIG are guidelines, and not requirements.
One final note: It's my personal opinion, that any time an initial screen like this is implemented, you should be able to tap to dismiss it.
Swift 2.0
Use following line in didFinishLaunchingWithOptions: delegate method:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
NSThread.sleepForTimeInterval(5.0)
return true
}
But I recommend this:
Put your image in a UIImageView full screen as a subview on the top of your main view thus covering your other UI. Set a timer to remove it after some seconds (possibly with effects) now showing your application.
import UIKit
class ViewController: UIViewController
{
var splashScreen:UIImageView!
override func viewDidLoad()
{
super.viewDidLoad()
self.splashScreen = UIImageView(frame: self.view.frame)
self.splashScreen.image = UIImage(named: "Logo.png")
self.view.addSubview(self.splashScreen)
var removeSplashScreen = NSTimer.scheduledTimerWithTimeInterval(3.0, target: self, selector: "removeSplashImage", userInfo: nil, repeats: false)
}
func removeSplashImage()
{
self.splashScreen.removeFromSuperview()
}
}
There is default image (default.png) is shown when you start your app.
So you can add a new viewcontroller which will display the that default image in the application didFinishLoading.
So by this logic you display the default image for a bit longer.
Swift version:
Add this line in the AppDelegate
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
NSThread.sleepForTimeInterval(2.0)//in seconds
return true
}