Discussion Forums  >  Uncategorized

Replies: 9    Views: 1549

michalis
Aspiring developer
Profile
Posts: 20
Reg: Jul 30, 2011
Athens
200
08/06/11 04:34 AM (14 years ago)

Is it possible to define the size of UIWebview window? (iOS / Buzztouch v 1.5)

I am new to the tool but I find it easy to use and extremely useful. I am developing an App that in one of the pages points to a particular frame on a website (not my own) to display a particular counter that is running there. Problem is this comes up too small on the left corner of my iPhone screen. Is there a way to define the size of the window I see on my view when I point to any website? If I was using IB Builder I could define the size if the UIWebview window and that would represent the size I see on the screen when I display a website, I tried this and it works with the same example. Is there a way to customize this within Buzztouch, as we have no .xib file here? Thanks
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/08/11 03:22 AM (14 years ago)
The size of the UIWebView is set in the BT_screen_webView.m file. Have a look at line 108 where it does: self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, browserTop, browserWidth, browserHeight)]; Frames are left, top, width, height. This means you could change the size and the posiiton of the view by changing these values. However, and this is important, if you change this you'll be chaning it for every screen you have setup that is using the BT_screen_webView.m file. To change it for one screen only, you'll need to figure out that screens unique id. You can do this by looking at the address bar while working with the control panel. When you're working with a screen, the id of the screen is: BT_itemId=9828E5AE542099A27F1E788 The value AFTER the equals sign the screen's id. So, you'll probably want to do something like... if([[self.screenData itemId] isEqualToString:@'9828E5AE542099A27F1E788']){ self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 200, 100)]; }else{ self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, browserTop, browserWidth, browserHeight)]; } Use your screens id instead of the sample I entered. Also, the single quotes in the sample need to be double quotes in xcode. Hope this helps get you pointed in the right direction.
 
michalis
Aspiring developer
Profile
Posts: 20
Reg: Jul 30, 2011
Athens
200
like
08/08/11 06:43 AM (14 years ago)
David, Your reply and code change suggestion solved my problem and showed me exactly what I need to do in the future in similar situations.... You not only provide a valuable software product but you also offer world class customer support for free. Thanks a million !!!
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/08/11 08:13 AM (14 years ago)
Woo hoo, glad it worked. After posting I also though of a way to do this with a Custom Plug-In. It's a bit trickier but may be a better long term solution? If you get some time, see if you can figure out how to... a) Create a new class file. the .m and the .h files. Name the new class whatever you want, like myCoolWebView.h and myCoolWebView.m b) Copy the code form the BT_screen_webView.m and .h files to your myCoolWebView.h and .m files. c) Change the name in the class files you created so they are myCoolWebView.m and .h (after you copy the contents of BT_screen_webView.m files you overwrite your names) d) You now have a custom-class file that is the same as the original BT_screen_webView.m, .h files. This can be used a as a custom-plugin and you can tweak, adjust, change things without breaking the original BT_screen_webView.m file. Use the control panel or see the docs to connect a menu item to your new custom class.
 
michalis
Aspiring developer
Profile
Posts: 20
Reg: Jul 30, 2011
Athens
200
like
08/08/11 09:06 AM (14 years ago)
Thanks again , will try that too.... On re-examining the original change though, I see that replacing the line: self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, browserTop, browserWidth, browserHeight)]; with the code you suggested: [if([[self.screenData itemId] isEqualToString:@99EA3BFCEAAD6E7742EDF87]){ self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)]; }else{ self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, browserTop, browserWidth, browserHeight)]; } forces ALL windows to that value(i.e. If loop does not work) plus the (Loading...) notification remains on screen when I load the page. Is there a specific line on the page I need to insert the code snippet? Thanks again! Should I have
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/08/11 09:10 AM (14 years ago)
That snippet should just replace the original line with: self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, browserTop, browserWidth, browserHeight)]; It's a matter of identifying which screen from your control panel is using the BT_screen_webView.m file to create itself. You could also look at the Output Console in Xcode with the app running to get some insights about which screen is loading, screen id's etc.
 
michalis
Aspiring developer
Profile
Posts: 20
Reg: Jul 30, 2011
Athens
200
like
08/08/11 04:33 PM (14 years ago)
I was finally able to fix everything, the page I want now displays in the frame I define while the others remain to normal setting. However I had to add the following IF satement too: //BuzzTouch Original: self.webView.scalesPageToFit = YES; //My Modification: if([[self.screenData itemId] isEqualToString:@99EA3BFCEAAD6E7742EDF87]){ self.webView.scalesPageToFit = NO; }else{ self.webView.scalesPageToFit = YES; } I really appreciate the feedback and suggestions, Thanks.
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
08/09/11 01:27 AM (14 years ago)
Ah...great find! The scale-pages-to-fit option should probably be added to the control panel. I'll look into it. Good post - thanks.
 
chrspe
Android Fan
Profile
Posts: 95
Reg: Jan 07, 2012
Buffalo, WY
5,400
like
02/05/12 09:35 AM (13 years ago)
I need to scale pages as described above, but being ferely new I can't find the BT_screen_webView.m file, I find the webview.java. Where is the BT_screen_webView.m located? Thanks.
 
rgtichy
Lost but trying
Profile
Posts: 104
Reg: Oct 14, 2011
Barrington
1,040
like
02/05/12 02:17 PM (13 years ago)
@chrspe-- You are probably close to the correct place; the webview.m and webview.h files are iOS conventions, they relate to objective-C, which , whereas the Android code is java based.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.