Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6647121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:29:59+00:00 2026-05-26T00:29:59+00:00

I am trying to make an OS X app that displays a WebView of

  • 0

I am trying to make an OS X app that displays a WebView of a mobile website using basic webview code, problem is I want this WebView to automatically load the mobile versions of whatever website it’s on.

 WebFrame *mainFrame = [web1 mainFrame];
NSURL *url = [NSURL URLWithString:@"http://www.website.com"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[mainFrame loadRequest:request]; 

So my question is, is there anything that I can add to the above code to make this web view identify itself to the server of what ever website it is on as a mobile browser, thus automatically loading the mobile version of any website it is on? I have already tried looking for the answer to this for myself online and haven’t had the least bit of luck finding the answer.

Thank you in advance for any and all help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:30:00+00:00Added an answer on May 26, 2026 at 12:30 am

    Yes

    Use an NSMutableURLRequest instead of a simple NSURLRequest, so you can alter it and use its setValue:forHTTPHeaderField: method to set the “User-Agent” HTML Header field to the User-Agent of MobileSafari.

    // You may adapt the UserAgent string depending on what device and Safari version you want to represent
    static NSString* const kMobileSafariUserAgent = @"Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8A293 Safari/6531.22.7";
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    [request setValue:kMobileSafariUserAgent forHTTPHeaderField:@"User-Agent"];
    [mainFrame loadRequest:request]; 
    

    For the User-Agent String to use, it depends on the version of MobileSafari you want to “emulate” (which version/device you want to make the server belives you are).

    See here for some of the UA strings possible

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make an app that displays something in real-world units. It's not
I'm trying to make a very simple iphone app that displays the real-time camera
I am trying to make an app that parses data from Twitter using JSON
I am trying to make an app that will pass data between two servers
I was wondering : I'm trying to make an app that as a Listview,
I'm trying to make a console app that would monitor some process and restart
I'm trying to make a simple app that sits on the Mac OSX menu
So I'm trying to make a console app that imposes a time limit to
I'm trying to make a very simple updater app that reads current version.txt file
I'm trying to make a tiny OS X app that would start a bash

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.