objective c - Requesting http://mobile.twitter.com on UIWebView -


i've been trying insert little webview (320x480) inside ipad app, simulate little "iphone screen" displaying mobile twitter. but, every time uiwebview gets nsurlrequest load http://mobile.twitter.com, app automatically gets ripped off screen, , ios opens twitter ipad.

is there way change behavior?

here's i'm doing:

uiwebview *viewdotwitter = [[uiwebview alloc] initwithframe:cgrectmake(0, 0, 320, self.view.bounds.size.height)]; viewdotwitter.autoresizingmask = uiviewautoresizingflexibleheight; viewdotwitter.scalespagetofit = yes;   [rootview insertsubview:viewdotwitter atindex:0];  [viewdotwitter loadrequest:[nsurlrequest requestwithurl:[nsurl urlwithstring:@"http://mobile.twitter.com"]]]; 

edited:

ok, found solution, here: http://www.mphweb.com/en/blog/easily-set-user-agent-uiwebview

 uiwebview *viewdotwitter = [[uiwebview alloc] initwithframe:cgrectmake(0, 0, 320, self.view.bounds.size.height)];  viewdotwitter.autoresizingmask = uiviewautoresizingflexibleheight;  viewdotwitter.scalespagetofit = yes;   nsdictionary *dictionnary = [[nsdictionary alloc] initwithobjectsandkeys:@"mozilla/5.0 (iphone; cpu iphone os 5_0 mac os x) applewebkit/534.46 (khtml, gecko) version/5.1 mobile/9a334 safari/7534.48.3", @"useragent", nil];  [[nsuserdefaults standarduserdefaults] registerdefaults:dictionnary];   [rootview insertsubview:viewdotwitter atindex:0];   [viewdotwitter loadrequest:[nsurlrequest requestwithurl:[nsurl urlwithstring:@"http://m.twitter.com"]]]; 

but, facing new problem: mobile.twitter.com insists adapt size of ipad screen, instead of 320 pixels width specified.

if doing this, shouldn't redirected

- (void)viewdidload {   [super viewdidload];   nsurl *url = [nsurl urlwithstring:@"http://mobile.twitter.com"];   nsurlrequest *request = [nsurlrequest requestwithurl:url];   [webview loadrequest:request]; } 

the behavior described achievable line of code (redirects):

[[uiapplication sharedapplication] openurl:url]; 

Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -