Dogboy Studios http://dogboystudios.com Making Stuff with Cocoa posterous.com Wed, 08 Feb 2012 16:42:00 -0800 Removing HTML elements from a UIWebView http://dogboystudios.com/removing-html-elements-from-a-uiwebview http://dogboystudios.com/removing-html-elements-from-a-uiwebview

I was working on a simple app to use UIWebVIews to display pages from a web site. Its a tab bar app and each tab loads a different page from the site.

The site is here: Tech Valley Mobile Developers Network

If you open that link in mobile safari you will see the extra elements added to aid browsing on the smaller screen.

The site is configured with a wordpress plug-in to better handle the mobile browser. The plug-in adds a menu, searching and the ability to toggle the mobile format on and off.

The home page looks like this:

Ios_simulator_screen_shot_feb_8_2012_7

I did not want these elements (the black bits at the top of the web view)  in the app as they would circumvent the tab bar button system.

It turns out, as with most things cocoa, once you figure it out its very simple.

 

The trick is to inject some html into the page after you load it. In this case I injected some javascript to hide content by id <div id=...> tag

 

Here is the code (apologies for the formatting)

- (void)hideUnwantedHTML{

    [self.webView stringByEvaluatingJavaScriptFromString:@"var script = document.createElement('script');"  

        "script.type = 'text/javascript';"  

        "script.text = \"function hideID(idName) { "  

        "var id = document.getElementById(idName);"  

        "id.style.display = 'none';"

     "}\";" 

 

     "document.getElementsByTagName('head')[0].appendChild(script);"];  

 

    [self.webView stringByEvaluatingJavaScriptFromString:@"hideID('headerbar');"];  

    [self.webView stringByEvaluatingJavaScriptFromString:@"hideID('wptouch-search');"];  

    [self.webView stringByEvaluatingJavaScriptFromString:@"hideID('wptouch-menu');"];  

    [self.webView stringByEvaluatingJavaScriptFromString:@"hideID('drop-fade');"];

    [self.webView stringByEvaluatingJavaScriptFromString:@"hideID('footer');"];    

}

 

What this method does is inject a script to find the element by name (idName) then hide any elements with that name. Call the script once for each id you want to hide.

Call this in your UIWebViewDelegate under the webViewDidFinishLoad: method and the nasty html you don't want will disappear.

 

- (void)webViewDidFinishLoad:(UIWebView *)webView {

    NSLog(@"Finished loading");

    UIApplication *application = [UIApplication sharedApplication];

    application.networkActivityIndicatorVisible = NO;

    [activityIndicator stopAnimating];

    activityIndicator.hidden = YES;

    [self hideUnwantedHTML];

}

 

 

Don't forget to add <UIWebViewDelegate> to your view controller in order to get the delegate calls.

Here is the same UIWebView after the addition of the injected javascript. Nice and clean.

Ios_simulator_screen_shot_feb_8_2012_7

Sure, web apps like this don't make the best apps but when a quick and dirty solution is needed this might just do the trick.

 

 

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1680501/me.png http://posterous.com/users/hd31xLH1rda1Y dogboystudios dogboystudios dogboystudios
Fri, 03 Feb 2012 13:29:00 -0800 Exporting is coming to CE Tracker http://dogboystudios.com/exporting-is-coming-to-ce-tracker http://dogboystudios.com/exporting-is-coming-to-ce-tracker

A few people have requested the ability to export their course data out of CE Tracker.

Ios_simulator_screen_shot_feb_3_2012_4

Version 1.2 will have this feature. 

This next version will also allow you to track expenses associated with courses so you can see how much compliance is costing you.

We have been planning these features for a while but it definitely motivates me when people submit requests. Keep the suggestions coming.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1680501/me.png http://posterous.com/users/hd31xLH1rda1Y dogboystudios dogboystudios dogboystudios
Wed, 25 Jan 2012 10:38:00 -0800 The Facebook Disaster http://dogboystudios.com/the-facebook-disaster http://dogboystudios.com/the-facebook-disaster

Excuse me venting here...

 

I am working on an app for a client. One of the features is sharing to twitter, facebook, etc.

In order to do so you need some API keys from the various sites to use in your app. I added half a dozen services with no problem. Then came facebook.

I have avoided creating a facebook page but it was needed in order to register an app as a developer. So I tried to sign up. I gave what I felt was the minimal information needed to start an account.

They decided that I was just going to spam them so they asked for a phone number to verify I was a real person. OK. Fair enough. I give them my google voice number to send me a text. I don't get the text. Repeat a few times. No text. Try again.  'You are requesting too many codes in a short period of time' Again, fair enough a bot network might do that.

Realzing this isn't going to work with text messaging and google voice, I give them a real live phone number and select the option to receive a voice call..... 'Our systems are busy. Try again later' Progress? Perhaps....

Repeat the process 3-4 times. Systems still busy. Really? You can't get a machine to dial my number and give me a code?? After 3-4 times it says I am spamming the system and locks me out again. Sometimes I can try again in a few hours sometimes 10-12 hours later it still says too many tries.

This has been going on for 3 days. Glad I didn't want the facebook page anyway.

Ended up using the client account to get the API key. Everything worked fine. For now.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1680501/me.png http://posterous.com/users/hd31xLH1rda1Y dogboystudios dogboystudios dogboystudios
Wed, 18 Jan 2012 13:57:00 -0800 CE Tracker 1.1 almost ready to go (for real this time) http://dogboystudios.com/ce-tracker-11-almost-ready-to-go-for-real-thi http://dogboystudios.com/ce-tracker-11-almost-ready-to-go-for-real-thi

A user has requested the ability to omit certain courses from counting for selected goals.

I thought this was a great idea so I added this feature to the next update.

 

Code is complete. A wee bit of testing and we will upload to App Store.

More planned for version 1.2 but please let me know if you have suggestions.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1680501/me.png http://posterous.com/users/hd31xLH1rda1Y dogboystudios dogboystudios dogboystudios
Mon, 09 Jan 2012 12:30:00 -0800 CE Tracker update now in App Store http://dogboystudios.com/ce-tracker-update-now-in-app-store http://dogboystudios.com/ce-tracker-update-now-in-app-store

As promised the bug fix release of CE Tracker should now be showing up as an update.

Didn't warrant the 1.1 version so we are going with 1.0.1

Have a few suggestions for the next feature update but I am open to more. Any input on making the app more useful in various professions and non-US locations is very helpful.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1680501/me.png http://posterous.com/users/hd31xLH1rda1Y dogboystudios dogboystudios dogboystudios
Wed, 21 Dec 2011 13:54:00 -0800 CE Tracker 1.1 Update Coming http://dogboystudios.com/ce-tracker-11-update-coming http://dogboystudios.com/ce-tracker-11-update-coming

Thanks to a user report I have fixed a bug that prevented the info button from displaying beyond the second goal in the goals view.

I am currently awaiting feedback on another possible bug (could be a misundertanding rather than a bug) but once this is clarified and fixed, if necessary, I will upload a new build to the app store.

Unfortunately, the App Store is shut down for updates until after the holidays so any update will take a few more days to appear.

If you have run across this issue please bear with me, the fix is on the way.

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1680501/me.png http://posterous.com/users/hd31xLH1rda1Y dogboystudios dogboystudios dogboystudios
Tue, 13 Dec 2011 05:41:00 -0800 Proxima is Available Now http://dogboystudios.com/proxima-is-available-now http://dogboystudios.com/proxima-is-available-now

Proxima has been approved and is available now for free in the App Store.

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1680501/me.png http://posterous.com/users/hd31xLH1rda1Y dogboystudios dogboystudios dogboystudios
Wed, 07 Dec 2011 09:47:00 -0800 What Next is now Proxima http://dogboystudios.com/what-next-is-now-proxima http://dogboystudios.com/what-next-is-now-proxima

I could have sworn I checked for name clashes in the App Store prior to even starting this project. Apparently I was wrong. So the app formally known as What Next is now Proxima.

Same great app, fresh new name.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1680501/me.png http://posterous.com/users/hd31xLH1rda1Y dogboystudios dogboystudios dogboystudios
Thu, 17 Nov 2011 15:04:00 -0800 What Next? http://dogboystudios.com/what-next http://dogboystudios.com/what-next

The paint is barely dry on CE Tracker and I am well underway on my next app.

This one is quick and dirty but it scratches an itch I have had for a while. With three kids and all sorts of family and work activites it is sometimes hard to track whats going on and where I need to be next. Sure a calendar will show you your schedule or a to do list will track your tasks but what I wanted is a simple one click app to tell me 'whats next?'

And thats what I'm working on.

5315d30d-5e5b-4894-a362-b930497c0a80

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1680501/me.png http://posterous.com/users/hd31xLH1rda1Y dogboystudios dogboystudios dogboystudios
Tue, 15 Nov 2011 05:22:00 -0800 CE Tracker in the App Store http://dogboystudios.com/ce-tracker-in-the-app-store http://dogboystudios.com/ce-tracker-in-the-app-store

App_store_badge

CE Tracker available in the App Store

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1680501/me.png http://posterous.com/users/hd31xLH1rda1Y dogboystudios dogboystudios dogboystudios
Mon, 07 Nov 2011 12:23:00 -0800 CE Tracker Submitted http://dogboystudios.com/ce-tracker-submitted-29630 http://dogboystudios.com/ce-tracker-submitted-29630

Iphone_4_gui_goals

Just finished uploading CE Tracker to the app store. CE Tracker is my iPhone app to help track continuing education compliance for professionals.

In many fields, such as law, medicine and engineering, licensed professionals are required to obtain a certain number of credits every year in order to maintain their licensing. Keeping track of the courses can be a tedious task. This is just the sort of job an iPhone is perfect for.

I tried to keep the app simple in appearance while maintaining a full feature set. If you enter the location for a class, seminar or event it can help you with directions using the iPhones mapping tools. If your license requires a certain amount of credits be in specifc areas of study it lets you track these requisites as well. If you are licensed in several states you can track them all. CE Tracker will figure out what credits apply to each of your licenses.

It took a lot longer than I expected. It always does but I never figured on shelving the project for 7 months. Anyway its been uploaded for review and if all goes well should be available in a few days.

You can read more about CE Tracker here

I'm happy with it and have of ideas on additional features. Lets see if anyone finds it useful.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1680501/me.png http://posterous.com/users/hd31xLH1rda1Y dogboystudios dogboystudios dogboystudios
Fri, 28 Oct 2011 09:36:00 -0700 Xcode4: Open files where you want http://dogboystudios.com/xcode4-open-files-where-you-want http://dogboystudios.com/xcode4-open-files-where-you-want

A new keyboard shortcut in Xcode4 allows you to quickly specify where a file opens in the editor.

Screen_shot_2011-10-28_at_12

Pressing Shift-Option and clicking on the file name in the Project Navigator brings up a quicklook type view in which you can click the location to display the new file. You can select the primary editor pane, the current assistant pane or a new assistant pane. A quick swipe in the 'quickview' window even lets you open the file in a new window. You can also select to open the file in a new tab.

 

Very handy. Very cool.

 

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1680501/me.png http://posterous.com/users/hd31xLH1rda1Y dogboystudios dogboystudios dogboystudios
Thu, 27 Oct 2011 13:40:00 -0700 Icon Design http://dogboystudios.com/icon-design http://dogboystudios.com/icon-design

Really working to come up on the correct icon for CE Tracker, my continuing education tracking app. I think I have a solid concept now but not 100% sure on the execution yet.

 

BTW new Pixelmator 2.0 is excellent

 

Cac9f3f45ea0e358571a6aa0370179c7

The background in the actual image is not a gradient. The icon generator adjusted it. Close enough for this sample.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1680501/me.png http://posterous.com/users/hd31xLH1rda1Y dogboystudios dogboystudios dogboystudios
Thu, 06 Oct 2011 07:36:00 -0700 Sad http://dogboystudios.com/sad http://dogboystudios.com/sad

Sad_mac

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1680501/me.png http://posterous.com/users/hd31xLH1rda1Y dogboystudios dogboystudios dogboystudios
Wed, 21 Sep 2011 17:25:00 -0700 Done... yeah sure http://dogboystudios.com/done-yeah-sure http://dogboystudios.com/done-yeah-sure

My long dormant app project is feature complete. Everything seems to work as it should. Squashed a few memory bugs when Instruments was cooperating. Seems good.

So I'm done right? Nah. Still got the other 80% of app development to do.

Back to work.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1680501/me.png http://posterous.com/users/hd31xLH1rda1Y dogboystudios dogboystudios dogboystudios
Fri, 16 Sep 2011 12:49:00 -0700 Working with iAd http://dogboystudios.com/working-with-iad http://dogboystudios.com/working-with-iad

Screen_shot
After jumping back into one of my long dormant projects yesterday I decided to implement iAd support. At this point I think this app will be free with the ads so this is a no brainer.

The iAd framework is very easy to work with but adding support to an app with a complex view heirarchy is work. Adding support to a complex view heirarchy hand coded and left dormant for almost a year is a nightmare.

I finally figured it out and my app now supports iAds in a tab view controller with a tableview. You won't understand the level of difficulty unless you have tried this. I'm sure if you started from scratch with the intent of having ad support it isn't very difficult but if you have no xib to tweak this sort of setup can be tricky.

I did a bunch of reading online but this tutorial really helped me get my head around it.

It works. I'm happy. Today was a good day.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1680501/me.png http://posterous.com/users/hd31xLH1rda1Y dogboystudios dogboystudios dogboystudios
Wed, 14 Sep 2011 13:26:00 -0700 Learning Cocos2D http://dogboystudios.com/learning-cocos2d http://dogboystudios.com/learning-cocos2d

Newbookcover192by250
Working my way through Learning Cocos2D. This is a very thorough book featuring a high level of detail for those looking to learn to use the Cocos2D framework. Lot of code to type (or copy/paste) but well worth the effort. A few more typos than I would like but nothing that can't be worked around. Full color code listings and illustrations.

This is the type of book that before you get more than a few chapters into it you are off on your own projects applying what you just learned. I'm normally the type that insists on doing everything by hand the hard way. I have developed games in the past only to burn out after writing the engine, editor and tools. Looking to bypass the hassle in the future. Cocos2D seems like an excellent framework with a very active community. Rather than developing your own engine and tools you can concentrate on making a game.

You will need a background in Obejctive-C programming. This is not a book for begining iOS developers. Highly recommended for aspiring game programmers looking for a crash course in Cocos2D.

Permalink | Leave a comment  »

]]>
http://files.posterous.com/user_profile_pics/1680501/me.png http://posterous.com/users/hd31xLH1rda1Y dogboystudios dogboystudios dogboystudios