Skip to content

Commit 455fba5

Browse files
committed
support for iphone
1 parent 653c7e0 commit 455fba5

9 files changed

+42
-15
lines changed

Default-Portrait~ipad.png

2.82 KB
Loading

Default.png

19.6 KB
Loading

XOSplash.xcodeproj/project.pbxproj

+15-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,12 @@
1515
083276D51579D1A500E68689 /* XOAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 083276D41579D1A500E68689 /* XOAppDelegate.m */; };
1616
083276D81579D1A500E68689 /* XOViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 083276D71579D1A500E68689 /* XOViewController.m */; };
1717
083276DB1579D1A500E68689 /* XOViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 083276D91579D1A500E68689 /* XOViewController.xib */; };
18-
083276E31579D2BF00E68689 /* splash.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 083276E21579D2BF00E68689 /* splash.mp4 */; };
1918
083276E51579D33900E68689 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 083276E41579D33900E68689 /* MediaPlayer.framework */; };
2019
083276E81579D3CD00E68689 /* XOSplashVideoController.m in Sources */ = {isa = PBXBuildFile; fileRef = 083276E71579D3CD00E68689 /* XOSplashVideoController.m */; };
2120
083276F0157A550500E68689 /* Default-Portrait~ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = 083276EF157A550500E68689 /* Default-Portrait~ipad.png */; };
21+
083276FC157AF31300E68689 /* splash-ipad.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 083276FA157AF31300E68689 /* splash-ipad.mp4 */; };
22+
083276FD157AF31300E68689 /* splash-iphone.mp4 in Resources */ = {isa = PBXBuildFile; fileRef = 083276FB157AF31300E68689 /* splash-iphone.mp4 */; };
23+
08327700157AFB0000E68689 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 083276FE157AFA5400E68689 /* Default.png */; };
2224
/* End PBXBuildFile section */
2325

2426
/* Begin PBXFileReference section */
@@ -35,11 +37,13 @@
3537
083276D61579D1A500E68689 /* XOViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XOViewController.h; sourceTree = "<group>"; };
3638
083276D71579D1A500E68689 /* XOViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XOViewController.m; sourceTree = "<group>"; };
3739
083276DA1579D1A500E68689 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/XOViewController.xib; sourceTree = "<group>"; };
38-
083276E21579D2BF00E68689 /* splash.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; name = splash.mp4; path = Resources/splash.mp4; sourceTree = "<group>"; };
3940
083276E41579D33900E68689 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = System/Library/Frameworks/MediaPlayer.framework; sourceTree = SDKROOT; };
4041
083276E61579D3CD00E68689 /* XOSplashVideoController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XOSplashVideoController.h; sourceTree = "<group>"; };
4142
083276E71579D3CD00E68689 /* XOSplashVideoController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XOSplashVideoController.m; sourceTree = "<group>"; };
4243
083276EF157A550500E68689 /* Default-Portrait~ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-Portrait~ipad.png"; sourceTree = "<group>"; };
44+
083276FA157AF31300E68689 /* splash-ipad.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; name = "splash-ipad.mp4"; path = "Resources/splash-ipad.mp4"; sourceTree = "<group>"; };
45+
083276FB157AF31300E68689 /* splash-iphone.mp4 */ = {isa = PBXFileReference; lastKnownFileType = file; name = "splash-iphone.mp4"; path = "Resources/splash-iphone.mp4"; sourceTree = "<group>"; };
46+
083276FE157AFA5400E68689 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = "<group>"; };
4347
/* End PBXFileReference section */
4448

4549
/* Begin PBXFrameworksBuildPhase section */
@@ -60,6 +64,7 @@
6064
083276B51579D1A500E68689 = {
6165
isa = PBXGroup;
6266
children = (
67+
083276FE157AFA5400E68689 /* Default.png */,
6368
083276EF157A550500E68689 /* Default-Portrait~ipad.png */,
6469
083276CA1579D1A500E68689 /* XOSplash */,
6570
083276C31579D1A500E68689 /* Frameworks */,
@@ -116,7 +121,8 @@
116121
083276E11579D22000E68689 /* Resources */ = {
117122
isa = PBXGroup;
118123
children = (
119-
083276E21579D2BF00E68689 /* splash.mp4 */,
124+
083276FA157AF31300E68689 /* splash-ipad.mp4 */,
125+
083276FB157AF31300E68689 /* splash-iphone.mp4 */,
120126
);
121127
name = Resources;
122128
sourceTree = "<group>";
@@ -175,8 +181,10 @@
175181
files = (
176182
083276CF1579D1A500E68689 /* InfoPlist.strings in Resources */,
177183
083276DB1579D1A500E68689 /* XOViewController.xib in Resources */,
178-
083276E31579D2BF00E68689 /* splash.mp4 in Resources */,
179184
083276F0157A550500E68689 /* Default-Portrait~ipad.png in Resources */,
185+
083276FC157AF31300E68689 /* splash-ipad.mp4 in Resources */,
186+
083276FD157AF31300E68689 /* splash-iphone.mp4 in Resources */,
187+
08327700157AFB0000E68689 /* Default.png in Resources */,
180188
);
181189
runOnlyForDeploymentPostprocessing = 0;
182190
};
@@ -270,6 +278,7 @@
270278
GCC_PREFIX_HEADER = "XOSplash/XOSplash-Prefix.pch";
271279
INFOPLIST_FILE = "XOSplash/XOSplash-Info.plist";
272280
PRODUCT_NAME = "$(TARGET_NAME)";
281+
TARGETED_DEVICE_FAMILY = "1,2";
273282
WRAPPER_EXTENSION = app;
274283
};
275284
name = Debug;
@@ -281,6 +290,7 @@
281290
GCC_PREFIX_HEADER = "XOSplash/XOSplash-Prefix.pch";
282291
INFOPLIST_FILE = "XOSplash/XOSplash-Info.plist";
283292
PRODUCT_NAME = "$(TARGET_NAME)";
293+
TARGETED_DEVICE_FAMILY = "1,2";
284294
WRAPPER_EXTENSION = app;
285295
};
286296
name = Release;
@@ -304,6 +314,7 @@
304314
083276E01579D1A500E68689 /* Release */,
305315
);
306316
defaultConfigurationIsVisible = 0;
317+
defaultConfigurationName = Release;
307318
};
308319
/* End XCConfigurationList section */
309320
};

XOSplash/Resources/splash-ipad.mp4

364 KB
Binary file not shown.

XOSplash/Resources/splash-iphone.mp4

224 KB
Binary file not shown.

XOSplash/Resources/splash.mp4

-44.6 KB
Binary file not shown.

XOSplash/XOAppDelegate.m

+11-3
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,22 @@ @implementation XOAppDelegate
1818

1919
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
2020
{
21-
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
21+
CGRect frame = [[UIScreen mainScreen] bounds];
22+
self.window = [[UIWindow alloc] initWithFrame:frame];
23+
24+
NSString *videoName = @"splash-iphone";
25+
NSString *imageName = @"Default.png";
26+
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
27+
videoName = @"splash-ipad";
28+
imageName = @"Default-Portrait~ipad.png";
29+
}
2230

2331
// our video
24-
NSURL *url = [[NSBundle mainBundle] URLForResource:@"splash" withExtension:@"mp4"];
32+
NSURL *url = [[NSBundle mainBundle] URLForResource:videoName withExtension:@"mp4"];
2533
// our splash controller
2634
XOSplashVideoController *splashVideoController =
2735
[[XOSplashVideoController alloc] initWithVideoURL:url
28-
imageName:@"Default-Portrait~ipad.png"
36+
imageName:imageName
2937
delegate:self];
3038
// we'll start out with the spash view controller in the window
3139
self.window.rootViewController = splashVideoController;

XOSplash/XOSplash-Info.plist

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<key>CFBundleIconFiles</key>
1616
<array>
1717
<string>Default-Portrait~ipad.png</string>
18+
<string>Default.png</string>
1819
</array>
1920
</dict>
2021
</dict>
@@ -38,6 +39,10 @@
3839
<array>
3940
<string>armv7</string>
4041
</array>
42+
<key>UISupportedInterfaceOrientations</key>
43+
<array>
44+
<string>UIInterfaceOrientationPortrait</string>
45+
</array>
4146
<key>UISupportedInterfaceOrientations~ipad</key>
4247
<array>
4348
<string>UIInterfaceOrientationPortrait</string>

XOSplash/XOSplashVideoController.m

+11-8
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ - (id)initWithVideoURL:(NSURL *)url
3232
UIImage *image = [UIImage imageNamed:imageName];
3333
_backgroundImageView = [[UIImageView alloc] initWithImage:image];
3434
CGRect backgroundFrame = frame;
35-
// shift the background frame down to allow for the status bar (which shows during the splash image)
36-
backgroundFrame.origin.y += [[UIApplication sharedApplication] statusBarFrame].size.height;
37-
backgroundFrame.size.height -= [[UIApplication sharedApplication] statusBarFrame].size.height;
35+
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
36+
// shift the background frame down to allow for the status bar, which shows and
37+
// takes up "sapce" during the splash image on ipad
38+
backgroundFrame.origin.y += [[UIApplication sharedApplication] statusBarFrame].size.height;
39+
backgroundFrame.size.height -= [[UIApplication sharedApplication] statusBarFrame].size.height;
40+
}
3841
_backgroundImageView.frame = backgroundFrame;
3942
[window addSubview:_backgroundImageView];
4043

@@ -81,10 +84,6 @@ - (void)splashLoadDidChange:(NSNotification *)notification
8184
// and play it
8285
[_player play];
8386

84-
// take the background image out, we're done with it
85-
[_backgroundImageView removeFromSuperview];
86-
_backgroundImageView = nil;
87-
8887
// tell the delegate that the video has loaded
8988
[_delegate splashVideoLoaded:self];
9089
}
@@ -98,7 +97,11 @@ - (void)splashDidFinished:(NSNotification *)notification
9897

9998
// tell our delegate that we're done playing
10099
[_delegate splashVideoLoaded:self];
101-
100+
101+
// take the background image out, we're done with it
102+
[_backgroundImageView removeFromSuperview];
103+
_backgroundImageView = nil;
104+
102105
// take our player out of the window, we're done with it
103106
[_player.view removeFromSuperview];
104107
_player = nil;

0 commit comments

Comments
 (0)