单击后退按钮时,iCarousel会显示在上一页中 [英] iCarousel is been shown up in previous page when clicked the back button

查看:54
本文介绍了单击后退按钮时,iCarousel会显示在上一页中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我按下后退按钮时. iCarousel 仍会显示1秒钟.为什么会发生这种情况以及如何阻止这种情况.我使用情节提要创建了一个iCarosel视图.

When i press the back button. the iCarousel is still shows up for 1 second.why is this happening and how to stop this.I have used storyboard to create a iCarosel view..

- (void)viewDidUnload
{
    [super viewDidUnload];
    self.carousel = nil;
}
- (void)dealloc
{
    carousel.delegate = nil;
    carousel.dataSource = nil;
}

- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
  return [idOfAllWords count];
}

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
    UILabel *label = nil;

    //create new view if no view is available for recycling
    if (view == nil)
    {
        view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 250.0f, 250.0f)];
        ((UIImageView *)view).image = [UIImage imageNamed:@"page.png"];
        view.contentMode = UIViewContentModeCenter;
        label = [[UILabel alloc] initWithFrame:view.bounds];
        label.backgroundColor = [UIColor clearColor];
        label.textAlignment = NSTextAlignmentCenter;
        label.font = [label.font fontWithSize:50];
        label.tag = 1;
        [view addSubview:label];
    }
    else
    {
        label = (UILabel *)[view viewWithTag:1];
    }
    Words *word=nil;
    word=idOfAllWords[index];
    label.text =word.Name;
    return view;
}

推荐答案

我实际上试图重现您的问题,并且确实看到在发生弹出"或后退按钮按下操作时,轮播视图会停留一秒钟.当您旋转轮播然后按下后退按钮时,尤其会发生这种情况.作为一种解决方法,我可以通过将iCarousel设置为隐藏在 viewWillDisappear 方法中来解决此问题.

I actually tried to reproduce your problem and did see that the carousel view stays for a second when 'pop' or back button press happens. This particularly happens when you the carousel is swiped and then the back button pressed. As a workaround, I was able to fix it by setting the iCarousel hidden in the viewWillDisappear method.

- (void)viewWillDisappear:(BOOL)animated 
{

[YOUR_CAROUSEL_NAME setHidden:YES]; //This sets the carousel to be hidden when you press Back button

}

如果这看起来突然被隐藏了,您可以尝试在动画块中将alpha设置为0.0.像这样:

If this looks to be hidden suddenly, you can perhaps try setting the alpha to 0.0 inside an animation block. Something like this:

- (void)viewWillDisappear:(BOOL)animated 
{

//[YOUR_CAROUSEL_NAME setHidden:YES]; 
[UIView animateWithDuration:0.2f animations:^{
   [YOUR_CAROUSEL_NAME setAlpha:0.0f]; //This makes the carousel hide smoothly
}];

}

希望这会有所帮助!

这篇关于单击后退按钮时,iCarousel会显示在上一页中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆