오늘 아침 iOS 8.0으로 업데이트되었습니다. 몇 가지 레이블을 만들고 일부 이미지 옆에 비틀기에 표시하는 코드 조각이 있습니다. 업데이트 전에 잘 작동했습니다. 이제 레이블과 이미지가 표시되지 않습니다. 내가 생각할 수있는 모든 것을 시도했지만 아무 것도 내 문제를 해결하지 못했고 비슷한 문제를 가진 다른 사람을 찾을 수 없었으므로 도움을받을 수 있습니까? 아래에 첨부 된 코드.iOS 8.0 업그레이드 후 UILabel이 표시되지 않습니다.
UIView *labelView = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, kCategoryLabelHieght)];
labelView.backgroundColor = [self colorWithHexString:@"2D2D2D"];
UILabel *categoryTitle = [[UILabel alloc] initWithFrame:CGRectMake(40, 0, 200, kCategoryLabelHieght)];
categoryTitle.textAlignment = NSTextAlignmentLeft;
categoryTitle.text = text;
categoryTitle.font = [UIFont fontWithName:@"HelveticaNeue" size:14];
codeAppDelegate *appDelegate = (codeAppDelegate *)[[UIApplication sharedApplication] delegate];
NSArray *fetchedCategory = [appDelegate getCategoryByName:text];
UIImageView *img=[[UIImageView alloc]initWithFrame:CGRectMake(10, 2, 20, 20)];
if(fetchedCategory.count)
{
for (int t=0; t<fetchedCategory.count; t++) {
Dealcategory_List *catList = [fetchedCategory objectAtIndex:t];
NSString *titleImage = [self URLEncodeString:[NSString stringWithFormat:@"%@",catList.image]];
NSURL *url = [NSURL URLWithString:titleImage];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *imgTabs = [UIImage imageWithData:data];
// [header2 setImage:imgTabs forState:UIControlStateNormal];
[imgTabs resizableImageWithCapInsets: UIEdgeInsetsMake(5, 10, 2, 0) resizingMode: UIImageResizingModeTile];
img.image= imgTabs;
}
}
else
{
NSArray *fetchedNewsCategory = [appDelegate getNewsCategoryByName:text];
if(fetchedNewsCategory.count > 0)
{
for (int t=0; t<fetchedNewsCategory.count; t++) {
News_Categories *catList = [fetchedNewsCategory objectAtIndex:t];
NSString *titleImage = [self URLEncodeString:[NSString stringWithFormat:@"%@",catList.category_image]];
NSURL *url = [NSURL URLWithString:titleImage];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *imgTabs = [UIImage imageWithData:data];
// [header2 setImage:imgTabs forState:UIControlStateNormal];
[imgTabs resizableImageWithCapInsets: UIEdgeInsetsMake(10, 10, 2, 0) resizingMode: UIImageResizingModeTile];
img.image= imgTabs;
}
}
else
{
NSArray *fetchedCompetition = [appDelegate getCompetitionByName:text];
if(fetchedCompetition.count > 0)
{
for (int t=0; t<fetchedCompetition.count; t++) {
Competitions_List *catList = [fetchedCompetition objectAtIndex:t];
NSString *titleImage = [self URLEncodeString:[NSString stringWithFormat:@"%@",catList.competition_tab_image]];
NSURL *url = [NSURL URLWithString:titleImage];
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *imgTabs = [UIImage imageWithData:data];
// [header2 setImage:imgTabs forState:UIControlStateNormal];
[imgTabs resizableImageWithCapInsets: UIEdgeInsetsMake(10, 10, 2, 0) resizingMode: UIImageResizingModeTile];
img.image= imgTabs;
break;
}
}
}
}
categoryTitle.textColor = color;
[labelView addSubview:img];
[labelView addSubview:categoryTitle];
[self.contentView addSubview:labelView];
코드를 스캔 할 때 나에게 이해가되지 않는 몇 가지 사항이 있습니다. A) 당신은 당신의'Categories 또는 NewsCategories or Competitions'를 거치고 그 이미지들을 당신의 이미지 뷰에 할당하고 이전 이미지를 대체합니다. 따라서 표시 할 이미지는 마지막 이미지뿐입니다. B)'resizableImageWithCapInsets'를 호출하고 결과를 버리고 있습니까? C)는 p4sh4의 포인트입니다. 다른 뷰를 할당하기 위해 labelView를 만드는 이유는 무엇입니까? 일반 "UIView"를 만들거나 두 개의 뷰를'contentView'에 직접 추가 하시겠습니까? – mackworth
'오늘 아침에 iOS 8.0에 업데이트되었습니다. '그런 다음해야 할 일은 8.0.2로 업데이트하는 것입니다 .-) – HAS