UIActivityIndi​​catorView没有动画(场景 - 有2个UIViews和2个UIActivityIndi​​catorObjects)

时间:2013-03-20 17:12:07

标签: ios uiactivityindicatorview iphone-5 iphone-4

我有一个用于启动画面的视图控制器,我已经处理了

  

A)两个方向 - >有两个UIViews,即viewPortrait,viewLandscape

     

B)两种屏幕尺寸 - > 3.5“,4”

我在viewPortrait上添加了UIActivityIndi​​catorView对象spinner1,并勾选了界面构建器中的“Animating”框。然后我在viewLandscape上添加了UIActivityIndi​​catorView对象spinner2并勾选了“Animating”框。

这里的问题是,当我加载应用程序时,微调器没有动画。但是,当我旋转时,我可以看到微调器动画。我做错了什么?请参阅下面的代码。

接口:

#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

0 个答案:

没有答案