Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 启动应用程序后,如何从Default.png淡入?_Iphone_Ios_Ipad_Default.png - Fatal编程技术网

Iphone 启动应用程序后,如何从Default.png淡入?

Iphone 启动应用程序后,如何从Default.png淡入?,iphone,ios,ipad,default.png,Iphone,Ios,Ipad,Default.png,启动iOS应用程序时,屏幕会从Default.png跳转到界面中。对于当前项目,我希望从Default.png淡入应用程序的界面。有什么好办法吗?是的,这并不难做到。我通过使用默认图像创建一个图像视图并设置动画来实现这一点。类似这样的内容(放入第一个视图控制器的viewDidLoad中): 然后执行removeAndDeleteCover并执行以下操作: [_coverImage removeFromSuperview]; 希望这会有帮助,如果你需要它作为一个通用的应用程序在iPad上运行,你

启动iOS应用程序时,屏幕会从Default.png跳转到界面中。对于当前项目,我希望从Default.png淡入应用程序的界面。有什么好办法吗?

是的,这并不难做到。我通过使用默认图像创建一个图像视图并设置动画来实现这一点。类似这样的内容(放入第一个视图控制器的viewDidLoad中):

然后执行removeAndDeleteCover并执行以下操作:

[_coverImage removeFromSuperview];

希望这会有帮助,如果你需要它作为一个通用的应用程序在iPad上运行,你必须检查这个案例并添加正确的默认图像。

有人在cocoacontrols.com上为它制作了一个控件


这里是它的链接:

我看了一点rooster117和runmad的答案,这就是我想到的

将UIImageView添加到第一个UIViewController的属性:

@interface DDViewController : UIViewController {
   ...
    UIImageView *coverImageView;
}

...

@property (nonatomic, retain) UIImageView *coverImageView;
然后,对于iPad应用程序的“主屏幕”,我称之为:

- (void)viewDidLoad
{
    [super viewDidLoad];

    ...

    coverImageView = [[UIImageView alloc] init];
}

-(void)viewWillAppear:(BOOL)animated {
    UIImage *defaultImage;   
    if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) {
        NSLog(@"Landscape!");
        defaultImage = [UIImage imageNamed:@"Default-Landscape.png"];
    } else {
        NSLog(@"Portrait!");
        defaultImage = [UIImage imageNamed:@"Default-Portrait.png"];
    }

    coverImageView = [[UIImageView alloc] initWithImage:defaultImage];
    [self.view addSubview:coverImageView];

}

-(void)viewDidAppear:(BOOL)animated {
    //Remove the coverview with an animation
    [UIView animateWithDuration:1.0f animations:^(void) {
        [self.coverImageView setAlpha:0.0];
    } completion:^(BOOL finished){
        [coverImageView removeFromSuperview];
    }];
}

扩展rooster117的答案,您需要正确加载最终的“着陆点”,即您希望用户实际与之交互的视图控制器,然后关闭“初始屏幕”视图控制器。这对于从网络加载数据的应用程序非常重要

我在ios7中似乎是这样做的,你认为它也应该在ios6中工作吗


如果使用故事板,您可以创建带有自定义序列的启动屏幕。虽然此代码是正确的,但我建议使用UIView动画块,它的编写和使用更简单、更简洁。我同意,但我正在尝试给出需要做什么的想法。我找到了使用UIView动画块的方法,然后四处寻找如何适应设备的方向。我的答案在上面。
- (void)viewDidLoad
{
    [super viewDidLoad];

    ...

    coverImageView = [[UIImageView alloc] init];
}

-(void)viewWillAppear:(BOOL)animated {
    UIImage *defaultImage;   
    if (UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation)) {
        NSLog(@"Landscape!");
        defaultImage = [UIImage imageNamed:@"Default-Landscape.png"];
    } else {
        NSLog(@"Portrait!");
        defaultImage = [UIImage imageNamed:@"Default-Portrait.png"];
    }

    coverImageView = [[UIImageView alloc] initWithImage:defaultImage];
    [self.view addSubview:coverImageView];

}

-(void)viewDidAppear:(BOOL)animated {
    //Remove the coverview with an animation
    [UIView animateWithDuration:1.0f animations:^(void) {
        [self.coverImageView setAlpha:0.0];
    } completion:^(BOOL finished){
        [coverImageView removeFromSuperview];
    }];
}