2012-06-16 6 views
0

이것은 간단한 질문입니다. QLPreviewController 구성 요소의 배경을 어떻게 변경합니까?변경 QLPreviewController 배경색

나는 PDF 파일을 표시하는 데 사용할하지만 배경 색상으로있는 ScrollView 패턴으로 나타납니다 :

[UIColor scrollViewTexturedBackgroundColor] 

내가 그 배경 색상 만 뷰의 backgroundColor 속성이 도움이되지 않는 변경을 변경하고 싶습니다.

아이디어가 있으십니까?

답변

0

하위 클래스를 만들어 변경해야합니다. 이런 식으로 뭔가 :

.H 파일 :

#import <QuickLook/QuickLook.h> 

@interface MyQLPreviewController : QLPreviewController 

하는 .m 파일 :

#import "MyQLPreviewController.h" 

@implementation MyQLPreviewController 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    self.view.backgroundColor = [UIColor redColor]; // make the change for example 
} 
+0

사실 내가 여기 이런 종류의 것들을 시도하기 전에 : 서브 클래 싱 된로드가 변경된 것으로 나타났습니다. 아무것도 나타나지 않았습니다. 아무 것도 작동하지 않는 것 같습니다. https://skitch.com/elbryan/eb8g3/ios-simulator –

0
나는 비슷한 문제가 발생하고 QLPreviewController를 서브 클래스와 구현에 다음을 추가 최대 끝났다

:

- (void)viewWillAppear:(BOOL)animated{ 
    [super viewWillAppear:animated]; 

    //Find webview and set its subviews' background color to white 
    [[self.view subviews] enumerateObjectsUsingBlock:^(UIView* view, NSUInteger idx, BOOL *stop) { 

     [self setSubviewsBackgroundColor:view]; 

    }]; 
} 

- (void)setSubviewsBackgroundColor:(UIView*)view{ 

    [[view subviews] enumerateObjectsUsingBlock:^(UIView* subview, NSUInteger idx, BOOL *stop) { 

     if ([subview isKindOfClass:[UIWebView class]]) { 

      [subview setBackgroundColor:[UIColor whiteColor]]; 
      [[subview subviews] enumerateObjectsUsingBlock:^(UIView* view, NSUInteger idx, BOOL *stop) { 
       [view setBackgroundColor:[UIColor whiteColor]]; 
      }]; 
     } 
     else [self setSubviewsBackgroundColor:subview]; 
    }]; 
} 

물론 [UIColor whiteColor]을 변경하고 필요에 맞게 위의 코드를 최적화하는 것이 좋습니다.

+2

이것은 iOS 5.1에서는 작동하지만 iOS 6에서는 작동하지 않습니다. 더 이상 UIWebView의 인스턴스를 사용하지 않는 것 같습니다. 그래도 UIView의 하위 뷰의 각 인스턴스에 배경색을 설정해도 작동하지 않습니다. –