UIWebView

Discussion in 'iOS Programming' started by yaniv92648, Apr 18, 2010.

  1. yaniv92648 macrumors member

    Joined:
    Oct 26, 2009
    #1
    Hi,
    how do i hide/remove the address bar from the UIWebView?
    how do i scroll programmtically a UIWebView?
    Thanks!
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
  3. yaniv92648 thread starter macrumors member

    Joined:
    Oct 26, 2009
    #3
    thanks for the scroll part,

    and the UIWebView does have an address bar, i'm doing loadRequest and on top of the web view there's a bar inwhich there a coordinates of the a specific location. i wanna hide that bar.
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    How have you created this UIWebView? When I create mine (which I do all in code, no Interface Builder) I don't get address bars. Maybe if you create them in Interface Builder you get an address bar?
     
  5. yaniv92648 thread starter macrumors member

    Joined:
    Oct 26, 2009
    #5
    all from code, no IB at all

    UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 80, 300, 200)];
    [webView setScalesPageToFit:YES];
    CGFloat currentLatitude = [[Order sharedOrder] location].latitude;
    CGFloat currentLongitude = [[Order sharedOrder] location].longitude;
    NSString *currentLocationString = [NSString stringWithFormat:mad:"%f,%f", currentLatitude, currentLongitude];
    NSString *urlString = [NSString stringWithFormat:mad:"http://maps.google.com/maps?q=%@&z=15", currentLocationString]; // z - zoom
    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]];
    [self.view addSubview:webView];
    [webView release];
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    Hmm, very odd. Can you post a screenshot of what you are getting. The only thing I do that you don't is set the webview delegate...
     
  7. yaniv92648 thread starter macrumors member

    Joined:
    Oct 26, 2009
    #7
    screenshot

    thank u
     

    Attached Files:

  8. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #8
    Is that address bar within the frame of your webview? As it might be part of the webpage Google has served up. Otherwise it certainly doesn't look like a standard Apple provided control...
     
  9. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #9
    Yeah, that bar may be within the content of the web view, but it is not part of the UIWebView, which doesn't have an address bar.
     
  10. yaniv92648 thread starter macrumors member

    Joined:
    Oct 26, 2009
    #10
    so..

    what u'r saying is i can't get rid of it??
     
  11. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #11
    No one said that. You will simply have to get more creative. I would have though that a bit of JavaScript/DOM action could remove it.
     
  12. yaniv92648 thread starter macrumors member

    Joined:
    Oct 26, 2009
    #12
    actually..

    in my case, there's a UILabel right above it, i could color the background of the label and hide the webview beneath the label, i kinda wanted something simpler.. but thank u all guys..
     
  13. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #13
    You probably should look into the Google Maps API and see if they have provided any mechanism to turn off that bar.


    P.S. And if you are using a UIWebView to provide only a Google Maps view, you should probably just consider using MKMapView.
     
  14. yaniv92648 thread starter macrumors member

    Joined:
    Oct 26, 2009
    #14
    i solved it at last...

    apparently javaScript is the only solution both to scroll and to hide the damn address bar..
    [webView stringByEvaluatingJavaScriptFromString:mad:"window.scrollTo(0, 120);"];
    the line above solved both of my problems.
    again, Thank u all for u'r help.
     

Share This Page