【问题标题】:Issue in i carousel and my custom animation我的轮播和我的自定义动画中的问题
【发布时间】:2012-06-28 06:31:34
【问题描述】:

我创建了一个应用程序,其中应用程序启动图像必须是动画的,并且我的按钮将使用 icarousel 以封面流效果显示..这是我的代码

- (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;    
//CGRect ChainbottomFrame = Chainbottom.frame;
//ChainbottomFrame.origin.y = self.view.bounds.size.height;

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


- (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;



 }

现在当我运行我的模拟器时,用于动画的图像返回并且按钮显示在前面。好消息是动画客栈图像正在工作......我也调整了我的 icarousel 视图的大小......

我错过了什么吗?...

【问题讨论】:

  • 先添加图片再添加按钮框怎么样。
  • 你的意思是说动画图像和按钮框架或按钮图像
  • 你制作了一个可以点击的按钮图片并会做相应的动作吧?
  • 是的。但我的问题是动画图像在按钮位于前面时返回...动画发生在 icarousel 按钮的后面...icarousel 是另一个视图,我调整了大小并将其放入UIView...
  • 如何将图像添加为视图的子视图?你在分配图像吗?

标签: iphone ios xcode uianimation icarousel


【解决方案1】:

我认为您在 iCarousel 视图中添加 imageView 错误, 试试这个:

[self.view addSubview:Chaintop];

并尝试调整图像大小。

希望这会有所帮助。

【讨论】:

  • 我还有一个问题...当特定视图控制器加载时会加载动画图像...但我只需要在我的应用程序启动时才需要?...
  • 像闪屏?你应该把它放在你的应用程序委托中。
  • 显示图像后放置一个 NSTimer 然后显示图像。
  • 我认为 NSTimer 只是用来显示时间的...是吗/
  • 不,您可以将它用于不同的目的。不如再问一个问题然后在那里回答。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2023-04-10
  • 1970-01-01
  • 1970-01-01
  • 2013-09-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多