Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.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/5/objective-c/24.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 如何将多个UIView包装在一个圆角矩形中进行排序(附图片)?_Ios_Objective C_Ios5_Ios6 - Fatal编程技术网

Ios 如何将多个UIView包装在一个圆角矩形中进行排序(附图片)?

Ios 如何将多个UIView包装在一个圆角矩形中进行排序(附图片)?,ios,objective-c,ios5,ios6,Ios,Objective C,Ios5,Ios6,在下图中,如何使多选项选择器和水平滚动条位于同一个白色圆形矩形中?它看起来非常适合排序,我很想实现类似的功能 您需要一个包含两个部分的UITableView(一个名为“section 1”,另一个名为“section 2”) 每个部分都有一行,每行的“单元格”在其“附件视图”中包含一个选项选择器 该选项选取器不是系统控件库的一部分,我不知道它从何而来。您可以将选项选取器作为UIScrollView,在UIView中附加一个UIPageControl,两个UIView(或UIImageView)

在下图中,如何使多选项选择器和水平滚动条位于同一个白色圆形矩形中?它看起来非常适合排序,我很想实现类似的功能


您需要一个包含两个部分的UITableView(一个名为“section 1”,另一个名为“section 2”)

每个部分都有一行,每行的“单元格”在其“附件视图”中包含一个选项选择器


该选项选取器不是系统控件库的一部分,我不知道它从何而来。

您可以将选项选取器作为UIScrollView,在UIView中附加一个UIPageControl,两个UIView(或UIImageView)提供透明淡入淡出效果。将n个视图添加到scrollview,每个视图具有相同的高度/宽度。如果需要快照(我想您会这样做),请使用UIScrollViewDelegories跟踪当前页面,如下所示:

-(void) scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    float pageWidth = scrollview.frame.size.width;
    int page = floor((scrollview.contentOffset.x - pageWidth / 2) / pageWidth) + 1;   
    [self scrollview:scrollview scrollToPage: page];       
}

-(void) scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    if( decelerate == FALSE )
    {
        float pageWidth = scrollview.frame.size.width;
        int page = floor((scrollview.contentOffset.x - pageWidth / 2) / pageWidth) + 1;

        [self scrollview:scrollview scrollToPage: page];
    }
}
scrollview:scrollToPage:方法将为您提供如下快照:

-(void) scrollview:(UIScrollView*) scrollview scrollToPage:(NSInteger) page
{
    [_myPageControl setCurrentPage:page];

    CGRect frame = scrollview.frame;
    frame.origin.x = frame.size.width * page;
    frame.origin.y = 0;
    [scrollview scrollRectToVisible:frame animated:YES];
}