2011-03-21 2 views
0

Three20 's TTLauncherView을 사용하고 있으며 고해상도 이미지를로드 한 경험이 있는지 의심 스럽습니까?iPhone/Objective-C TTLauncher보기 URL에서 고해상도 이미지로드

http://three20.info/showcase/launcher

TTLauncherItem 년대를 설정하려면 다음 방법을 사용하고 있습니다 :

NSString *imageUrl = [self displayImageUrl:@"http://foo.com/lowres.png" withHighResUrl:@"http://foo.com/hires.png"; 
TTLauncherItem *launcherItem = [[[TTLauncherItem alloc] initWithTitle:@"Icon1" 
                   image:imageUrl 
                    URL:@"Icon1" 
                  canDelete:NO] autorelease]; 

이것은 내가 그것이 iOS4의 여부를 결정하는 데 사용하는 방법입니다.

- (NSString *)displayImageUrl:(NSString *)standardResUrl withHighResUrl:(NSString *)highResUrl { 
    NSString *imageUrl = nil; 
    if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2) { 
     imageUrl = highResUrl; 
    } else { 
     imageUrl = standardResUrl; 
    } 

    return imageUrl; 
} 

문제는 아이폰 4 아래 모든 iOS 장비가 제대로 표시하기 반면 이미지가 실제로 아이폰 4에 자신의 모든 차원에 표시지고 있다는 점이다. TTLauncherView 라이브러리를 변경해야하는지 또는 이러한 문제를 해결하는 더 쉬운 방법이 있는지 궁금합니다.

답변

2

launcherButtonImage를 기반으로하는 새 스타일을 320 스타일 시트에 추가하여이 작업을 수행했습니다. 이 ... 원래이다

 - (TTStyle*)launcherButtonImage:(UIControlState)state { 
     TTStyle* style = 
     [TTBoxStyle styleWithMargin:UIEdgeInsetsMake(-7, 0, 11, 0) next: 
     [TTShapeStyle styleWithShape:[TTRoundedRectangleShape shapeWithRadius:8] next: 
     [TTImageStyle styleWithImageURL:nil defaultImage:nil contentMode:UIViewContentModeCenter 
         size:CGSizeZero next:nil]]]; 

     if (state == UIControlStateHighlighted || state == UIControlStateSelected) { 
      [style addStyle: 
      [TTBlendStyle styleWithBlend:kCGBlendModeSourceAtop next: 
      [TTSolidFillStyle styleWithColor:RGBACOLOR(0,0,0,0.5) next:nil]]]; 
     } 

    return style; 
} 

... 그리고 아마 당신이 둥근 이미지의 모서리와 같이 필요가 없습니다 거기에 물건있다

- (TTStyle*)favoriteLauncherButtonImage:(UIControlState)state { 

    TTStyle* style = 
    [TTShapeStyle styleWithShape:[TTRoundedRectangleShape 
            shapeWithRadius:4.0] next: 
    [TTBoxStyle styleWithMargin:UIEdgeInsetsMake(0, 0, 0, 0) 
         padding:UIEdgeInsetsMake(16, 16, 16, 16) 
         minSize:CGSizeMake(0, 0) 
         position:TTPositionStatic next: 
     [TTImageStyle styleWithImageURL:nil defaultImage:nil contentMode:UIViewContentModeScaleAspectFit 
           size:CGSizeMake(64, 64) next: nil 
     ]]]; 

    if (state == UIControlStateHighlighted || state == UIControlStateSelected) { 
     [style addStyle: 
     [TTBlendStyle styleWithBlend:kCGBlendModeSourceAtop next: 
      [TTSolidFillStyle styleWithColor:RGBACOLOR(0,0,0,0.5) next:nil]]]; 
    } 

    return style; 
} 

이 ... 업데이트 된 버전입니다. 작동 부분은 이미지 크기를 64x64로 고정시키는 TTImageStyle 지시어입니다. 희망이 도움이됩니다.

1

나는 SDWebImage 사용해보십시오

대신 Three20의 TTLauncherView을 사용하고 있습니다 :

https://github.com/rs/SDWebImage

당신은 그냥하는 UIImageView에 두 부하를 발급 대한 높은 하나 하나의 수를 낮은 res 이미지. 저해상도가 먼저 완료되어야합니다 ...

+0

감사합니다. 문제는 이미지로드/캐싱이 아닙니다. TTLauncherView에는 내가 아는 한 고해상도 이미지를로드 할 수있는 기능이 없습니다. – fuzz

+1

ThreeTwenty를 사용하는 바로 그 사실은 본질적으로 문제입니다. 변경을 고려 중이더라도, 원하는 것을하기 위해 변경해야하는 경우에도 다른 것으로 이동할 필요가 있음을 의미합니다. ThreeTwenty는 프레임 워크 중 가장 처음이었고, 잘 작성되지 않았으며, 대부분의 측면은 더 좋은 프레임 워크로 대체되어 중단 된 부분을 차지했습니다. –

+0

잔소리, 마지막 질문의 의미를 이해하지 못합니다. 일반적으로 SDWebImage를 사용하는 방식은 로컬 자리 표시 자이며 배경에 고해상도 이미지를로드하는 URL입니다. 나는 대개 UIImageView를 scaleAspectFit으로 설정했기 때문에 이미지가 더 크면 망막과 비 망막 디스플레이 (그리고 iPad 유형은 2 배 크기의 iPhone 응용 프로그램을 실행하는 망막과 같은 역할을합니다)에서 잘 보일 것입니다. –