feat: 智念app iOS 第一次提交
This commit is contained in:
161
HBuilder-Hello/ViewController.m
Normal file
161
HBuilder-Hello/ViewController.m
Normal file
@@ -0,0 +1,161 @@
|
||||
//
|
||||
// ViewController.m
|
||||
// Pandora
|
||||
//
|
||||
// Created by Mac Pro_C on 12-12-26.
|
||||
// Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
#import "ViewController.h"
|
||||
#import "PDRToolSystem.h"
|
||||
#import "PDRToolSystemEx.h"
|
||||
#import "AppDelegate.h"
|
||||
|
||||
#define kStatusBarHeight 20.f
|
||||
|
||||
@implementation ViewController
|
||||
|
||||
- (void)loadView
|
||||
{
|
||||
PDRCore *h5Engine = [PDRCore Instance];
|
||||
[super loadView];
|
||||
[self setStatusBarStyle:h5Engine.settings.statusBarStyle];
|
||||
_isFullScreen = [UIApplication sharedApplication].statusBarHidden;
|
||||
if ( _isFullScreen != h5Engine.settings.fullScreen ) {
|
||||
_isFullScreen = h5Engine.settings.fullScreen;
|
||||
if ( [self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)] ) {
|
||||
[self setNeedsStatusBarAppearanceUpdate];
|
||||
} else {
|
||||
[[UIApplication sharedApplication] setStatusBarHidden:_isFullScreen];
|
||||
}
|
||||
}
|
||||
self.view.backgroundColor = [UIColor whiteColor];
|
||||
[h5Engine setContainerView:self.view];
|
||||
h5Engine.persentViewController = self;
|
||||
if ( self.showLoadingView ) {
|
||||
[h5Engine showLoadingPage];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)viewDidAppear:(BOOL)animated {
|
||||
[super viewDidAppear:animated];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
|
||||
duration:(NSTimeInterval)duration
|
||||
{
|
||||
[[PDRCore Instance] handleSysEvent:PDRCoreSysEventInterfaceOrientation
|
||||
withObject:[NSNumber numberWithInt:toInterfaceOrientation]];
|
||||
if ([PTDeviceOSInfo systemVersion] >= PTSystemVersion8Series) {
|
||||
[[UIApplication sharedApplication] setStatusBarHidden:_isFullScreen ];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotate
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
|
||||
{
|
||||
return [[PDRCore Instance].settings supportedInterfaceOrientations];
|
||||
}
|
||||
|
||||
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
|
||||
{
|
||||
if ( [PDRCore Instance].settings ) {
|
||||
return [[PDRCore Instance].settings supportsOrientation:interfaceOrientation];
|
||||
}
|
||||
return UIInterfaceOrientationPortrait == interfaceOrientation;
|
||||
}
|
||||
|
||||
- (BOOL)prefersStatusBarHidden
|
||||
{
|
||||
return _isFullScreen;/*
|
||||
NSString *model = [UIDevice currentDevice].model;
|
||||
if (UIUserInterfaceIdiomPhone == UI_USER_INTERFACE_IDIOM()
|
||||
&& (NSOrderedSame == [@"iPad" caseInsensitiveCompare:model]
|
||||
|| NSOrderedSame == [@"iPad Simulator" caseInsensitiveCompare:model])) {
|
||||
return YES;
|
||||
}
|
||||
return NO;*/
|
||||
}
|
||||
|
||||
- (UIStatusBarAnimation)preferredStatusBarUpdateAnimation {
|
||||
return UIStatusBarAnimationFade;
|
||||
}
|
||||
|
||||
-(BOOL)getStatusBarHidden {
|
||||
if ( [PTDeviceOSInfo systemVersion] > PTSystemVersion6Series ) {
|
||||
return _isFullScreen;
|
||||
}
|
||||
return [UIApplication sharedApplication].statusBarHidden;
|
||||
}
|
||||
|
||||
#pragma mark - StatusBarStyle
|
||||
-(UIStatusBarStyle)getStatusBarStyle {
|
||||
return [self preferredStatusBarStyle];
|
||||
}
|
||||
-(void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle {
|
||||
if ( _statusBarStyle != statusBarStyle ) {
|
||||
_statusBarStyle = statusBarStyle;
|
||||
if ( [self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)] ) {
|
||||
[self setNeedsStatusBarAppearanceUpdate];
|
||||
} else {
|
||||
[[UIApplication sharedApplication] setStatusBarStyle:_statusBarStyle];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (UIStatusBarStyle)preferredStatusBarStyle
|
||||
{
|
||||
return _statusBarStyle;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
-(void)wantsFullScreen:(BOOL)fullScreen
|
||||
{
|
||||
if ( _isFullScreen == fullScreen ) {
|
||||
return;
|
||||
}
|
||||
|
||||
_isFullScreen = fullScreen;
|
||||
[[UIApplication sharedApplication] setStatusBarHidden:_isFullScreen withAnimation:_isFullScreen?NO:YES];
|
||||
if ( [PTDeviceOSInfo systemVersion] > PTSystemVersion6Series ) {
|
||||
[self setNeedsStatusBarAppearanceUpdate];
|
||||
}// else {
|
||||
// return;
|
||||
// }
|
||||
CGRect newRect = self.view.bounds;
|
||||
if ( [PTDeviceOSInfo systemVersion] <= PTSystemVersion6Series ) {
|
||||
newRect = [UIApplication sharedApplication].keyWindow.bounds;
|
||||
if ( _isFullScreen ) {
|
||||
[UIView beginAnimations:nil context:nil];
|
||||
self.view.frame = newRect;
|
||||
[UIView commitAnimations];
|
||||
} else {
|
||||
UIInterfaceOrientation interfaceOrientation = [UIApplication sharedApplication].statusBarOrientation;
|
||||
if ( UIDeviceOrientationLandscapeLeft == interfaceOrientation
|
||||
|| interfaceOrientation == UIDeviceOrientationLandscapeRight ) {
|
||||
newRect.size.width -=kStatusBarHeight;
|
||||
} else {
|
||||
newRect.origin.y += kStatusBarHeight;
|
||||
newRect.size.height -=kStatusBarHeight;
|
||||
}
|
||||
[UIView beginAnimations:nil context:nil];
|
||||
self.view.frame = newRect;
|
||||
[UIView commitAnimations];
|
||||
}
|
||||
[[PDRCore Instance] handleSysEvent:PDRCoreSysEventInterfaceOrientation
|
||||
withObject:[NSNumber numberWithInt:0]];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning{
|
||||
[[PDRCore Instance] handleSysEvent:PDRCoreSysEventReceiveMemoryWarning withObject:nil];
|
||||
}
|
||||
|
||||
- (void)dealloc {
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user