I’m trying to determine if I could detect when a request is coming from iOS UIWebView, and in such cases, return a custom layout.
Here’s the scenario. Currently I have a mobile web view built entirely in Rails, and it looks like this:

This loads in the browser and works fine. Now, I’m working on an iOS app built in Xcode that will mix native code with UIWebViews. What I’ve done at this point is build the red nav bar natively. I want the rest of the site (everything with the white background) to load in the UIWebView.
Ideally, I would do this by detecting if the request is coming from within an iOS app. If that’s the case the layout would not include the red nav bar (as that is already being handled natively). If the request is coming from the browser, then the layout would include the red nav bar.
I’ve searched around but can’t find anything on this. Does anyone know how to pull something like this off?
You could add a custom header to your native iOS app URL call by doing
[request setValue:@"true" forHTTPHeaderField:@"My-iOSApp"]to aNSMutableURLRequest(this may be different depending on what system you are using for HTTP networking in your iOS app)Then use
request.headersto get the headers in Rails and inspect them to see if theMy-iOSAppkey is in the headers. If it is, then only render the bottom body layout otherwise render the whole thing with the nav bar