私はIOS 6でxcode 4.5を使用して1つのアプリケーションを開発しています.StroyBoardでMaster Detail View Controllerを使用しています.1つのUIScrollviewがあり、その中でいくつかのxmlファイルを画像名で解析して複数の画像を追加しています. do while ループを使用して、UIScrollview. に複数の画像を追加しています。また、cellSeparator という名前の別の UIView があり、その UIView には、UIScrollView に読み込まれた画像を説明するラベルをいくつか追加しています。
今私の問題は、cellSeparator ビューのラベルの位置が適切な位置になく、すべてのラベルが互いに上書きされることです..誰でも私を助けることができます..?
以下は、私が上で言ったように、このすべてのものを作成する私の関数です...
-(void) traverseElement:(TBXMLElement *)element {
//この Do While ループ関数が 3 回または 4 回反復するとします...そして 3 回または 4 回の画像を // UIScrollView に追加します
do {
if ([[TBXML elementName:element] isEqualToString:@"subcategory"]) {
TBXMLAttribute *idAttribute = element->firstAttribute;
int i = [[TBXML attributeValue:idAttribute] intValue];
checkSubCategoeyId =i;
}
if (element->firstChild)
[self traverseElement:element->firstChild];
if(subCategoryId == checkSubCategoeyId && [[TBXML elementName:element] isEqualToString:@"item"])
{
[self removeSubviewsOfView];
int k=2001;
TBXMLAttribute *idAttribute = element->firstAttribute;
int j = [[TBXML attributeValue:idAttribute] intValue];
//This is my logic which will get data from my rest service and convert in to NSString Object which i will assign to labeltext
NSString *imageName = [TBXML textForElement:itemImageName];
NSString *id = [NSString stringWithFormat:@"%d",j];
NSString *url=@"http://192.168.3.12:8732/Service1/data/";
NSString* strRR = [NSString stringWithFormat:@"%@%@", url, id];
[self getDataFrom:strRR];
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
UILabel *indexLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, self.view.frame.size.height-150, self.view.frame.size.width/2,30)];
[indexLabel setBackgroundColor:[UIColor clearColor]];
indexLabel.textColor = [UIColor whiteColor];
indexLabel.text = @"Details:-";
indexLabel.font = [UIFont systemFontOfSize:20.00];
UILabel *tagLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, self.view.frame.size.height-120, self.view.frame.size.width/2, 30)];
tagLabel.backgroundColor = [UIColor clearColor];
tagLabel.text = [NSString stringWithFormat:@"The Id of Jewl Is: %@",imageId];
imageTypelabel = [[UILabel alloc] initWithFrame:CGRectMake(20, self.view.frame.size.height-90, self.view.frame.size.width/2, 30)];
imageTypelabel.backgroundColor = [UIColor clearColor];
imageTypelabel.text = [NSString stringWithFormat:@"The Type of Jewl Is: %@",imageType];
imageStylelabel= [[UILabel alloc] initWithFrame:CGRectMake(20, self.view.frame.size.height-60, self.view.frame.size.width/2, 30)];
imageTypelabel.backgroundColor = [UIColor clearColor];
imageStylelabel.text = [NSString stringWithFormat:@"The style of Jewl Is: %@",imageStyle];
imageWeightlabel = [[UILabel alloc] initWithFrame:CGRectMake(20, self.view.frame.size.height-30, self.view.frame.size.width/2, 30)];
imageStylelabel.backgroundColor = [UIColor clearColor];
imageWeightlabel.text = [NSString stringWithFormat:@"The weight of Jewl Is: %@",imageWeight];
imageWeightlabel.backgroundColor = [UIColor clearColor];
imageWeightlabel.textColor = [UIColor whiteColor];
imageTypelabel.textColor = [UIColor whiteColor];
imageStylelabel.textColor = [UIColor whiteColor];
tagLabel.textColor = [UIColor whiteColor];
UIImage *imageBegin = [UIImage imageNamed:imageName];
UIImageView *imageView = [[UIImageView alloc] initWithImage:imageBegin];
UIView *cellSeparator = [[UIView alloc] initWithFrame:CGRectMake(0,545, self.view.frame.size.width ,3)];
[cellSeparator setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleWidth];
[cellSeparator setContentMode:UIViewContentModeTopLeft];
[cellSeparator setBackgroundColor:[UIColor whiteColor]];
[self.view addSubview:cellSeparator];
imageView.frame = CGRectMake(scrollX, scrollY,imageBegin.size.width , imageBegin.size.height);
imageView.center = CGPointMake(self.view.center.x+scrollX, self.view.center.y-100);
UIImage *mirrorImage = [UIImage imageNamed:imageName];
UIImageView *mirrorImageView = [[UIImageView alloc] initWithImage:mirrorImage];
mirrorImageView.frame = CGRectMake(scrollX, scrollY+imageView.frame.size.height-100, imageView.frame.size.width, 60);
mirrorImageView.transform=CGAffineTransformMakeRotation(3.14);
[mirrorImageView setBackgroundColor:[UIColor clearColor]];
mirrorImageView.alpha= 0.2;
mirrorImageView.center = CGPointMake(imageView.center.x, imageView.center.y+imageView.frame.size.height/2);
UIPinchGestureRecognizer *pinchRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchDetected:)];
[imageView addGestureRecognizer:pinchRecognizer];
[pinchRecognizer setDelegate:self];
imageView.userInteractionEnabled = YES;
UIRotationGestureRecognizer *rotationRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotationDetected:)];
[imageView addGestureRecognizer:rotationRecognizer];
[rotationRecognizer setDelegate:self];
[itemScroll addSubview:indexLabel];
[itemScroll addSubview:imageTypelabel];
[itemScroll addSubview:imageWeightlabel];
[itemScroll addSubview:imageStylelabel];
[itemScroll addSubview:tagLabel];
[itemScroll addSubview:mirrorImageView];
imageView.userInteractionEnabled =YES;
[itemScroll addSubview:imageView];
self.itemScroll.delegate=self;
scrollX = scrollX+self.view.frame.size.width;
}
} while (element = element->nextSibling);
}
cellSeparator ビューを x と y の位置とラベルの x と y の位置に配置して、適切な場所に配置できるようにするための適切な解決策を誰かに教えてもらえますか。
以下は、ビュー全体のグラフィカル表現です