Ios4 如何在ipad中查找最后一个视图宽度

Ios4 如何在ipad中查找最后一个视图宽度,ios4,uiview,cgrectmake,Ios4,Uiview,Cgrectmake,我正在mainview中添加视图。如何查找上次插入的视图宽度 NSArray *noPotions = [NSArray arrayWithObjects:@"1",@"2",@"3",@"4", nil]; int list = [noPotions count]; int lastPosition = 10; int widthValue = 100; for (int i = 0; i < list ; i++) { UIView *newView = [[UIV

我正在mainview中添加视图。如何查找上次插入的视图宽度

  NSArray *noPotions = [NSArray arrayWithObjects:@"1",@"2",@"3",@"4", nil];
int list = [noPotions count];

int lastPosition = 10;

int widthValue = 100;

for (int i = 0; i < list ; i++) {
    UIView  *newView = [[UIView alloc]initWithFrame:CGRectMake(lastPosition, 10, widthValue, 60)];
    [newView.layer setBorderColor:[[UIColor blueColor] CGColor]];
    [self.view addSubview:newView];
    lastPosition = newView.bounds.size.width + 20;
    newView.layer.borderWidth = 4;

    [newView release];
NSArray*noPotions=[NSArray数组,其对象为:@“1”,“2”,“3”,“4”,无];
int list=[noPotions count];
int lastPosition=10;
int宽度值=100;
对于(int i=0;i
在此代码中,最后一个位置始终为120。
有人能帮我吗?

你可以先给FOR循环中的UIView添加标签

for (int i = 0; i < list ; i++) 
{
     UIView  *newView = [[UIView alloc]initWithFrame:CGRectMake(lastPosition, 10, widthValue, 60)];
     newView.tag = i;
     [newView.layer setBorderColor:[[UIColor blueColor] CGColor]];
     [self.view addSubview:newView];
     lastPosition = newView.bounds.size.width + 20;
     newView.layer.borderWidth = 4;

     [newView release];
}
UIView* latestView = [self.view viewWithTag:[list count]-1];