1

i'm trying to display pdf file in uiwebview. my pdf files have different size. one can see the shadow or gradient outside of pdf in uiwebview. i've tried different solution but with no luck. see the link. how can i get rid of those shadows?

uiwebview shadow

duplicate with this answer, but not working for me the code accepted as aswer there:

webView.backgroundColor = [UIColor whiteColor];
for (UIView* subView in [webView subviews])
{
    if ([subView isKindOfClass:[UIScrollView class]]) {
        for (UIView* shadowView in [subView subviews])
        {
            if ([shadowView isKindOfClass:[UIImageView class]]) {
                [shadowView setHidden:YES];
            }
        }
    }
}
Community
  • 1
  • 1
Hashmat Khalil
  • 1,826
  • 1
  • 25
  • 49
  • that shadow is from pdf. you cant get rid of it. see my comment below. otherwise both code snippte are to get rid of uiwebview shadows. you will still have pdf shadow inside the view. – Hashmat Khalil Mar 12 '12 at 16:14

1 Answers1

-1

There a several threads around here with this topic …

Try this:

for(UIView *wview in [[[webView subviews] objectAtIndex:0] subviews]) { 
  if([wview isKindOfClass:[UIImageView class]]) { wview.hidden = YES; } 
}

It should work and pass App Store submission, because it's not using any private APIs.

dom
  • 11,894
  • 10
  • 51
  • 74
  • 1
    yes i know this code too. i tried it once more. but still i see the shadows. – Hashmat Khalil Mar 08 '12 at 12:46
  • @user I tried it again myself and it's working fine -> http://cl.ly/040g300i3f0I0p270L0H – dom Mar 11 '12 at 13:18
  • yeah i have tried it's working to get rid of shadows from uiwebviews. but i was confused when tried to display pdf. so that shadow in the screen shot is pdf shadow. i found it later. so i ended up not using uiwebview, but quartz. and that was another long story. thanks anyway! – Hashmat Khalil Mar 12 '12 at 16:12
  • @user If you need some "inspiration" about PDF rendering, check out this project: https://github.com/vfr/Reader – dom Mar 12 '12 at 16:17