0

我在 Scrollview 中创建饼图,这是主视图的子视图,然后我将 pieChart 添加为滚动视图的子视图,但它不显示饼图

我有以下代码

   -(void)loadNews{

NSArray *graphs = [[NSArray alloc] initWithObjects:@"1", nil];

NSInteger numberofPages=[graphs count];


for (int i = 0; i < [graphs count]; i++) {

    CGRect frame;
    frame.origin.x = self.scrollView.frame.size.width * i;
    frame.origin.y = 0;
    frame.size = self.scrollView.frame.size;
    UIView*subView=[[UIView alloc ]initWithFrame:frame];
    [self.scrollView addSubview:subView];


    //PieClass *myPieClass=[[PieClass alloc]initWithFrame:CGRectMake(250,450,320,230)];
    PieClass *myPieClass=[[PieClass alloc]initWithFrame:CGRectMake(327,470,320,230)];

    //myPieClass.backgroundColor=[UIColor clearColor];
    myPieClass.backgroundColor=[UIColor blackColor];

    myPieClass.itemArray=[[NSArray alloc]initWithObjects:valueOne,valueTwo,valueThree,valueFour, nil];

    myPieClass.myColorArray=[[NSArray alloc]initWithObjects:[UIColor blueColor],[UIColor redColor],[UIColor greenColor],[UIColor brownColor], nil];

    myPieClass.radius=100;

    [subView addSubview:myPieClass];

}




self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * graphs.count, self.scrollView.frame.size.height);
[pageControl setNumberOfPages:numberofPages];

[pageControl setActivePageColor:[UIColor colorWithRed:36/255.0 green:71/255.0 blue:113/255.0 alpha:1.0]];
[pageControl setInactivePageColor:[UIColor lightGrayColor]];

}
4

1 回答 1

0

在 CGRectMake(327,470,320,230) 您正在设置 327,470 的原点

尝试类似 CGRectMake(100,100,320,230)。

于 2012-05-16T11:34:48.390 回答