0

スプラッシュスクリーン用のView Controllerがあり、処理しました

A) 両方の向き -> viewPortrait、viewLandscape という 2 つの UIView を使用

B) 両方の画面サイズ -> 3.5 インチ、4 インチ

viewPortrait に UIActivityIndi​​catorView オブジェクト spinner1 を追加し、インターフェイス ビルダーで [Animating] ボックスにチェックを入れました。次に、viewLandscape に UIActivityIndi​​catorView オブジェクト spinner2 を追加し、「アニメーション」ボックスにチェックを入れました。

ここでの問題は、アプリをロードすると、スピナーがアニメーション化されないことです。ただし、回転すると、スピナーのアニメーションが表示されます。私は何を間違えましたか?以下のコードを参照してください。

インターフェース:

#import <UIKit/UIKit.h>
#import "homeViewController.h"

@interface splashViewController : UIViewController

@property (nonatomic,retain) IBOutlet UIView *viewPortrait;
@property (nonatomic,retain) IBOutlet UIView *viewLandscape;
@property (nonatomic,retain) IBOutlet UIActivityIndicatorView *spinner1;
@property (nonatomic,retain) IBOutlet UIActivityIndicatorView *spinner2;
@property (nonatomic,retain) IBOutlet UIImageView *splash;

- (void) loadHomeView;
- (void) detectOrientation:(NSNotification *) obj;

@end

実装ファイル:

#import "splashViewController.h"

@implementation splashViewController
@synthesize splash,spinner1,spinner2,viewLandscape,viewPortrait;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {}
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(detectOrientation:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return YES;
}

- (void) detectOrientation: (NSNotification *) obj {
    CGSize result=[[UIScreen mainScreen] bounds].size;
    UIDeviceOrientation dev = [[obj object]orientation];
    if(dev == UIInterfaceOrientationPortrait || dev == UIInterfaceOrientationPortraitUpsideDown) {
        self.view = self.viewPortrait;
        self.splash.contentMode = UIViewContentModeScaleAspectFit;
        if(result.height==568) [self.spinner1 setCenter:CGPointMake(157.0,360.0)];
    }
    else {
        self.view = self.viewLandscape;
        if(result.height==568) {
            [self.spinner2 setCenter:CGPointMake(284.0,270.0)];
            self.splash.image = [UIImage imageNamed:@"Default-568.png"];
        }
    }
//    [NSTimer scheduledTimerWithTimeInterval:5.0f target:self selector:@selector(loadHomeView) userInfo:nil repeats:NO];
}

- (void) loadHomeView {
    [self.spinner1 stopAnimating];
    [self.spinner2 stopAnimating];
    [self.spinner1 release];
    [self.spinner2 release];
    homeViewController *hv = [[[homeViewController alloc]initWithNibName:@"homeViewController" bundle:nil] autorelease];
    [self presentViewController:hv animated:NO completion:nil];
}

@end
4

0 に答える 0