无法为轮播的最后一项设置偏移值?

时间:2014-07-03 07:51:39

标签: ios iphone icarousel

enter image description here我在我的应用程序中使用iCarousel来显示来自带有线性类型轮播的Web服务的图像。当用户滚动轮播结束时如果没有来自网络服务的图像我正在添加一个带按钮的轮播。 我正在做的是当没有来自Web服务的数据我设置布尔值是(isNoImagesAvailable == YES)。然后我在底部添加一个额外的轮播项目。

下面是了解我如何做的示例代码

 if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
    {

        self.carousel.contentOffset = CGSizeMake(0, (213 - self.carousel.frame.size.height) * 0.5);

    }
    else
    {
        self.carousel.contentOffset = CGSizeMake(0, (200 - self.carousel.frame.size.height) * 0.5);
    }

- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{

 //Here i am increasing carousel count by 1 if no images available
    if (isNoImagesAvailable)
    {

        return images.count+1;
    }
    else
    {
    return images.count;
    }
}


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

    //create new view if no view is available for recycling

  if(index < images.count  )
{
    if (view == nil)
    {
        //this `if (view == nil) 
{`        
        view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200.0f, 200.0f)];
        ((UIImageView *)view).image =// Here loading images from web service
        view.contentMode = UIViewContentModeCenter;

    }
    else


    return view;
}
// if no images are available adding one button with text "No data available" 
else
    {
        UIView * endimageView = nil;
            if (view == nil)
            {
                endimageView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 150.0f,50.0f)];
                endimageView.backgroundColor =[UIColor clearColor];
                endimageView.contentMode = UIViewContentModeCenter;
                UIButton *noDataButton =[UIButton buttonWithType:UIButtonTypeCustom];
                noDataButton.frame =CGRectMake(0, 0, 150, 40);
                noDataButton.userInteractionEnabled=YES;
                [noDataButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
                [noDataButton setTitle:@"No data available" forState:UIControlStateNormal];
                [noDataButton addTarget:self action:@selector(popToHomePage) forControlEvents:UIControlEventTouchUpInside];
                noDataButton.backgroundColor =[UIColor whiteColor];
                [endingDealView addSubview: noDataButton s];


            }

        return endingDealView;

    }

这里的问题是当用户在屏幕底部向上滚动“无数据可用”按钮进入导航栏下方时。如何使“endimageView”轮播项目偏移到导航栏下方的确切位置。

让我知道我身边需要的任何信息  感谢

0 个答案:

没有答案