Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 10    Views: 62

AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
02/08/15 02:00 PM (9 years ago)

Solved-Adding a webview to a menu plugin to display html content

I am looking to add an html based window of text content, positioned not unlike a banner advert, to one of the existing menus - probably Menu Image Advanced, at the top. My app is both Ios and android. I am aiming to display some updating html text (two lines) in that window, with the menu rows below that content. There is no clicking on links needed. So I'm guessing that I need to to add a webview and I can hard-code the url for that content as it won't change. The web page is under my control, so I can style and size the content to make it fit. I am not a programmer, so I am looking to cut and paste from something that already exists, or is close, if I can. Can anyone point me in a good direction please? Thanks in advance, Alan
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
02/08/15 03:25 PM (9 years ago)
Do you have the ultimate screen creator plugin?
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
02/08/15 03:32 PM (9 years ago)
I have bought a few of your plugins Chris, but not that one I'm afraid.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/08/15 03:38 PM (9 years ago)
Have you thought about an image instead of a webpage? Pretty close to the same appearance, already built into the Menu Image Advanced plugin. Cheers! -- Smug
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
02/08/15 03:45 PM (9 years ago)
Smug - that's a great idea. You could replace the image view in that plugin with a web view too, but web views tend to be more complicated than simple image views from a coding perspective.
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
02/08/15 04:05 PM (9 years ago)
Thanks for the ideas. I wish it could be an image, but the content is a countdown to the next event, with a description of the event, which has been done in javascript.
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
02/08/15 04:14 PM (9 years ago)
Do you have the Cubbyholes plugin? If yes, then the code for the webview is clear as daylight (or mud) within it's own method. -- Niraj
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
02/10/15 11:43 AM (9 years ago)
I borrowed some code from the internet and with some help from another post, I have it working. For those who would like to do this one day, here is what I did: I used this post to work out how to prepare the web view: http://stackoverflow.com/questions/14474142/xcode-4-5-os-x-cocoa-application-basic-web-view-load-google-when-opened I used the existing variables to position the web view and push the menu rows down. I Used this post to work out how to restrict the modification to only work on just the one screen where I want it: https://www.buzztouch.com/forum/thread.php?fid=6FC010911DD2224F55E5401&tid=6FC010911DD2224F55E5401 This is the code I ended up with: // mods to add a webview if([self.screenData.itemId isEqualToString:@"149993CEC831F690EFB89EE" ]) // hardwired for only the screen where used { CGFloat webviewHeight = 80; // the height of the webview // the start height of the webview is the image height - ie after the banner, if it is there self.myWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, imageHeight + theTop, imageWidth, webviewHeight)]; _myWebView.opaque = NO; _myWebView.backgroundColor = [UIColor clearColor]; // set the background [self.view addSubview:self.myWebView]; // to be transparent NSURL *myURL = [NSURL URLWithString:@"http://www.limetimeapps.co.uk/appfiles/gpracefan/f1countdown2015.html"]; NSURLRequest *myRequest = [NSURLRequest requestWithURL:myURL]; [self.myWebView loadRequest:myRequest]; imageHeight=imageHeight+webviewHeight; // reset the start position of the tableview } // end of mods to add a webview I dropped it into the viewDidLoad method just before the point where the menu items rectangle was about to be created and it shows under the menu banner and before the 1st row. //generate the frame for tableview right below the image.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
02/10/15 11:50 AM (9 years ago)
Good job!
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
02/10/15 12:04 PM (9 years ago)
Thanks Chris.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/10/15 04:25 PM (9 years ago)
Sweet. It's going in the snippet library for later use! Thanks Alan! Cheers! -- Smug
 

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.