gpt4 book ai didi

iphone - 使用 NStimer 设置默认图像的图像动画

转载 作者:行者123 更新时间:2023-11-28 22:53:43 25 4
gpt4 key购买 nike

如何在应用程序启动时集成两个图像,其中一个作为默认图像,另一个作为动画图像。即使再次加载 View ,动画图像也不应该再次出现。它应该只在应用程序启动时出现,如 default.png 图像。 .我的想法是获得两个默认图像..我该怎么做?..

这是我的代码...

@interface ViewController ()<UIActionSheetDelegate>

@property (nonatomic, assign) BOOL useButtons;

@end

@implementation ViewController

@synthesize carousel,Chaintop;

#pragma mark -
#pragma mark View lifecycle

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
carousel.type = iCarouselTypeInvertedWheel ;

CGRect ChaintopFrame = Chaintop.frame;
ChaintopFrame.origin.y = self.view.bounds.size.height;

[UIView animateWithDuration:3
delay:1.0
options: UIViewAnimationCurveEaseOut
animations:^{
Chaintop.frame = ChaintopFrame;
//Chainbottom.frame = ChainbottomFrame;
}
completion:^(BOOL finished){
NSLog(@"Done!");
}];
[self.view addSubview: Chaintop];
}


- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
return NUMBER_OF_ITEMS;
}

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{

UIImage *buttonImage=[NSArray arrayWithObjects:[UIImage imageNamed:@"Cover_0.png"],
[UIImage imageNamed:@"Cover_1.png"],
[UIImage imageNamed:@"Cover_2.png"],
[UIImage imageNamed:@"Cover_3.png"],
[UIImage imageNamed:@"Cover_4.png"],
[UIImage imageNamed:@"Cover_5.png"],
[UIImage imageNamed:@"Cover_6.png"],
[UIImage imageNamed:@"Cover_7.png"],nil];

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 200.0f, 200.0f);

[button setImage:(UIImage*)[buttonImage objectAtIndex:index] forState:UIControlStateNormal];

[button addTarget:self action:@selector(buttonTapped:) forControlEvents:UIControlEventTouchUpInside];
return button;



}

-(void)dealloc{
[Chaintop release];

}



- (BOOL)carousel:(iCarousel *)_carousel shouldSelectItemAtIndex:(NSInteger)index
{
if (index == carousel.currentItemIndex)
{
NSLog(@"Should select current item");
}
else
{
NSLog(@"Should select item number %i", index);
}
return YES;
}

- (void)carousel:(iCarousel *)_carousel didSelectItemAtIndex:(NSInteger)index
{
if (index == carousel.currentItemIndex)
{
//note, this will only ever happen if useButtons == NO
//otherwise the button intercepts the tap event
NSLog(@"Did select current item");
}
else
{
NSLog(@"Did select item number %i", index);
}
}
@end

最佳答案

在您的 APP DELEGATE 中。像这样的东西应该可以完成这项工作:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
UIImageView *imageView = [[[UIImageView alloc] initWithFrame:self.window.bounds] autorelease];
UIImage *image = [UIImage imageNamed:@"NAMEOFYOURSPLASHSCREEN.png"];
imageView.image = image;
[self.window addSubview:imageView];
[self.window makeKeyAndVisible];
[self performSelector:@selector(remove1stSplash:) withObject:imageView afterDelay:5];
return YES;
}

- (void)remove1stSplash:(UIImageView *)1stView {
UIImageView *imageView = ...
[self.window addSubview:imageView];
[self performSelector:@selector(remove2ndSplash:) withObject:imageView afterDelay:5];
[1stView removeFromSuperView];
}

- (void)remove2ndSplash:(UIImageView *)2ndView {
[self.window addSubview:.....
[2ndView removeFromSuperView];
}

编辑:

示例项目链接: Two Splash Screen display in iphone

关于iphone - 使用 NStimer 设置默认图像的图像动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11248852/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com