Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/101.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.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
Ios UIPageControl+循环(无限)滚动_Ios_Iphone_Objective C_Uiscrollview_Uipagecontrol - Fatal编程技术网

Ios UIPageControl+循环(无限)滚动

Ios UIPageControl+循环(无限)滚动,ios,iphone,objective-c,uiscrollview,uipagecontrol,Ios,Iphone,Objective C,Uiscrollview,Uipagecontrol,我正在开发的应用程序中,我必须使欢迎屏幕。在UIPageControl中,我需要显示不同的9个子视图。也需要无限循环滚动在那。这意味着如果我在第9页之后滑动,第1页应该出现 我已经尽了很大的努力来实现它,但从未得到预期的结果 有人能帮我找到最好的解决方案吗 谢谢。我建议使用它来完成此任务。我在那里做了如下更改演示按钮演示 .h级 硕士班 或点击按钮索引:- - (void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger

我正在开发的应用程序中,我必须使欢迎屏幕。在UIPageControl中,我需要显示不同的9个子视图。也需要无限循环滚动在那。这意味着如果我在第9页之后滑动,第1页应该出现

我已经尽了很大的努力来实现它,但从未得到预期的结果

有人能帮我找到最好的解决方案吗

谢谢。

我建议使用它来完成此任务。我在那里做了如下更改演示按钮演示

.h级

硕士班

或点击按钮索引:-

- (void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index
{
    NSLog(@"Tapped view number: %d", index);
}
它的输出是:-


试试这个或这个,我能知道谁和为什么否决了这个问题吗?如果你有胆量的话,请把反对票投给谁,然后说出反对票的理由。
- (void)viewDidLoad
{
    [super viewDidLoad];
    _wrap = YES;
    //configure carousel
    carousel.type = iCarouselTypeLinear;
}

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

    return 9;
}


- (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, 200.0f, 400)];
        view.backgroundColor=[UIColor redColor];
        ((UIImageView *)view).image = [UIImage imageNamed:@"page.png"];
        view.contentMode = UIViewContentModeCenter;
        label = [[UILabel alloc] initWithFrame:view.bounds];
        label.backgroundColor = [UIColor clearColor];
        label.textAlignment = UITextAlignmentCenter;
        label.font = [label.font fontWithSize:50];
        label.tag = 1;
        [view addSubview:label];
    }
    else
    {
        //get a reference to the label in the recycled view
        label = (UILabel *)[view viewWithTag:1];
    }

       label.text = [NSString stringWithFormat:@"%i", index];

    return view;
}


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

    //create new view if no view is available for recycling
    if (view == nil)
    {
        //don't do anything specific to the index within
        //this `if (view == nil) {...}` statement because the view will be
        //recycled and used with other index values later
        view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 200.0f, 400.0f)];
        view.backgroundColor=[UIColor redColor];

        ((UIImageView *)view).image = [UIImage imageNamed:@"page.png"];
        view.contentMode = UIViewContentModeCenter;

        label = [[UILabel alloc] initWithFrame:view.bounds];
        label.backgroundColor = [UIColor clearColor];
        label.textAlignment = UITextAlignmentCenter;
        label.font = [label.font fontWithSize:50.0f];
        label.tag = 1;
        [view addSubview:label];
    }
    else
    {
        //get a reference to the label in the recycled view
        label = (UILabel *)[view viewWithTag:1];
    }

        label.text = (index == 0)? @"[": @"]";

    return view;
}


- (CGFloat)carousel:(iCarousel *)_carousel valueForOption:(iCarouselOption)option withDefault:(CGFloat)value
{
    //customize carousel display
    switch (option)
    {
        case iCarouselOptionWrap:
        {
            //normally you would hard-code this to YES or NO
            return _wrap;
        }
        case iCarouselOptionSpacing:
        {
            //add a bit of spacing between the item views
            return value * 1.05f;
        }
        case iCarouselOptionFadeMax:
        {
            if (carousel.type == iCarouselTypeCustom)
            {
                //set opacity based on distance from camera
                return 0.0f;
            }
            return value;
        }
        default:
        {
            return value;
        }
    }
}
- (CATransform3D)carousel:(iCarousel *)_carousel itemTransformForOffset:(CGFloat)offset baseTransform:(CATransform3D)transform
{
    //implement 'flip3D' style carousel
    transform = CATransform3DRotate(transform, M_PI / 8.0f, 0.0f, 1.0f, 0.0f);
    return CATransform3DTranslate(transform, 0.0f, 0.0f, offset * carousel.itemWidth);
}
- (void)carousel:(iCarousel *)carousel didSelectItemAtIndex:(NSInteger)index
{
    NSLog(@"Tapped view number: %d", index);
}