Archive February, 2010

iPhone: Delete the shadow effect when scrolling a UIWebView

In this last period I worked on three applications for Apple iPhone, virtually simultaneously. Two have already been approved by Apple and are located on the App Store: thefirst and iMakeLove .

TheFirst iMakeLove

In both applications have adopted the use of an object UIWebView to display the instructions.
The object UIWebView has ilevato really convenient in this case. It allowed me to quickly view and a nice text, images, and accompanied, if anything else was displayed on a Web page (Flash on iPhone not included).

TheFirst

The object UIWebView is truly versatile and requires very few settings to be used. The only defect is the presence of a mysterious shadow that appears when you make a scroll out of the area of ​​control is at the bottom than at the top:

UIWebView Shadow

After much research I realized that this behavior depends on the SDK, especially the latest updates. And Apple has not released any official statement on how to remove it, on the contrary, he rejected as code is not allowed a series of hacks that make use of sensitive functions, or documenting. Eventually I gave up, both for time and because the solutions seemed all out of the box Apple.
Fortunately I got the solution, I hope fairly regular basis, which seems to solve the problem (thanks to Adolfo ):

1
2
3
4
5
6
/ / WebView is the control UIWebView
[ webView.subviews objectAtIndex : 0 ] ; id = scroller [webView.subviews objectAtIndex: 0];

UIView * subView in [ scroller subviews ] ) for (UIView * subView in [scroller subviews])
subView class ] description ] isEqualToString : @ "UIImageView" ] ) if ([[[subView class] description] isEqualToString: @ "UIImageView"])
; subView.hidden = YES;

As pointed out by Adolfo this is still a hack that could stop working with future releases of the SDK.

More ...

How to locate images and views in Interface Builder

After explaining how to locate our strings in Xcode , as we see now is simple - applying the same technique - to locate and view images / interfaces created with Interface Builder.

Locate graphic resources

The process, as mentioned, is the same, if we have an image already included in our resources, or they insert a new one, and we want to "locate" - that is, managing two or more images based on the languages ​​supported - just click the button Right image ( Adium.png in this example) and select Get Info:

We click Make File Localizable in the lower left.

Click on Add and insert Localization Italian :

In order to obtain:

esattamente come accadeva con il testo: Our image is moved (physically, one of the rare times when that happens nell'alberatura Xcode is reflected on the filesystem) under virtual folders English.lproj and Italian.lproj exactly as happened with the text:

contiene una stessa versione dell'immagine. At this point each of the folders English.lproj and Italian.lproj contains the same version of the image. This image is manipulated within Interface Builder, where we will see - by default - the English version.
At this point, just overwrite one (or both files Adium.png ) to obtain a localization of the images "flash".

Locate the files XIB

Even the interfaces built with Interface Builder can be localized in their entirety, when it is deemed necessary. ) con interfaccia XIB , lo selezioniamo, scegliamo Get Info dal menu contestuale, rendiamo il file localizzabile, aggiungiamo la localizzazione in italiano: The procedure is identical to that performed with the graphical capabilities: add a ViewController (eg infoViewController ) XIB interface, we select it, choose Get Info from the contextual menu, give the file localizable, add localization in Italian:

ViewController

Click on English or Italian will open Interface Builder! ) all'interno della classica cartella Classes . This time, the filesystem, we will notice that you have created two directories ( English.lproj and Italian.lproj ) within the classical Classes folder. Both will have their files infoViewController.xib . The comfort in this, clearly resolved in the code, when we go to instantiate our controller code we will have a "clean" like this:

1
2
[ InfoViewController alloc ] ; InfoViewController * info = [InfoViewController alloc];
info.view ] ; [Self.view addSubview: info.view];

As you can see there is no trace of any statement concerning the location, totally managed by the system. The two interfaces, of course, can be completely different in that they are in all respects as two separate files XIB.

More ...

How to create your own protocol with delegated

Even in the most simple tutorial you can find the use of protocols. It will certainly happen to many of your view controller used in a protocol, inputting, next to the definition of the interface, a statement similar to:

1
2
3
UIViewController <uiwebviewdelegate> { @ Interface myViewController: UIViewController {<uiwebviewdelegate>
...
}

More ...

WordPress: filter the content of the comments

I've had to fix an annoying problem on a WordPress blog: users left comments with long sentences. This produced the release of the text, both in the backend, even worse, in the frontend. The effect was really horrible and to avoid hand-to moderate every single comment, the only solution was to filter out - somehow - the output of the comments.

More ...

Very short snippet: get the output of a URL in Objective-C

Perhaps I should write "Very very very, short snippets", however, is an excellent and convenient "trick" that I am going to show. Executing the "two" lines of code shown below, you can get the output of any URL and manipulate it.

More ...


Stop SOPA