How implement a UIActivityIndicatorView when the UIWebView is Loading? (iPhone ObjC) - iphone

I want to know how to implement an activityIndicator in a WebView based app, I wrote the following code but the indicator does not appear.
The webview load file locally, so it load very fast, but when it load an external page it load slow and I need the indicator...
FirstViewController.h
#import <UIKit/UIKit.h>
#interface FirstViewController :
UIViewController <UIWebViewDelegate>{
IBOutlet UIWebView *webview1;
NSURL *urlLocation;
IBOutlet UIActivityIndicatorView *m_activity;
}
#property (nonatomic, retain) UIActivityIndicatorView *m_activity;
- (IBAction)searchbutton:(id)sender;
- (IBAction)home:(id)sender;
#end
FirstViewController.m
#import "FirstViewController.h"
#implementation FirstViewController
#synthesize m_activity;
// viewWillAppear loads every time younopen up this View
- (void)viewWillAppear:(BOOL)animated {
NSString *filePath = [[NSBundle mainBundle] pathForResource:#"index" ofType:#"html"];
urlLocation = [NSURL fileURLWithPath:filePath];
[webview1 loadRequest:[NSURLRequest requestWithURL:urlLocation]];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
//Initialization code
m_activity = nil;
}
return self;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
m_activity.hidden= TRUE;
[m_activity stopAnimating];
NSLog(#"Web View started loading...");
}
- (void)webViewDidStartLoad:(UIWebView *)webView {
m_activity.hidden= FALSE;
[m_activity startAnimating];
NSLog(#"Web View Did finish loading");
}

Why are you setting your activity indicator to nil in your init?
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
//Initialization code
m_activity = nil;
}
return self;
}
The call to super initialized your indicator from your XIB (assuming you connected it to your outlet in IB), but then you are setting the reference to nil after it's been initialized. Remove that line. Then go back into interface builder and set the "Hide when stopped" checkbox. Now you can simplify your code that displays the indicator:
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[m_activity stopAnimating];
}
- (void)webViewDidStartLoad:(UIWebView *)webView {
[m_activity startAnimating];
}
The "Hide when stopped" causes the indicator to hide when you stop it from animating.

Whats the issue here, the code you posted above should work, except that you dont initialize the indicator anywhere (maybe you do in viewDidLoad) but the code shown above should work given that the indicator was initialized correctly and u set the webview d elegate to the view controller there, I have it working on some of my apps where i use webviews and indicators to indicate when its loading...

UIWebView.loading property can also be used.
Apple's doc:
#property(nonatomic, readonly, getter=isLoading) BOOL loading
Description
A Boolean value indicating whether the receiver is done loading content. (read-only)
If YES, the receiver is still loading content; otherwise, NO.
In iOS6 it looks like Apple has fixed some issues with this property as well. http://code-gotcha.blogspot.fi/2012/08/uiwebviewloading-in-ios-6-fixed.html

Related

How to add MWPhotoBrowser project referance in my own iphone image gallery apps?

I want to make an iphone app like the native iphone photo gallery....i found a project MWPhotoBrowser and now i want to use some feature of this project....but i don't know how to do this....i am new in iphone apps development..
First, you have to import in your project the "framework" you had downloaded. Then, you have to make a class "viewController" (the .h and .m files) and set the view like this:
.h should be like this
#import <UIKit/UIKit.h>
#import "MWPhotoBrowser.h"
#interface PhotoLoader : UIViewController<MWPhotoBrowserDelegate> {
NSArray *_photos;
UISegmentedControl *_segmentedControl;
}
#property (nonatomic, retain) NSArray *photos;
#end
the file. m shoud be like this
// PhotoLoader.m
#import "PhotoLoader.h"
#interface PhotoLoader ()
#end
#implementation PhotoLoader
#synthesize photos = _photos;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Create browser
MWPhotoBrowser *browser = [[MWPhotoBrowser alloc] initWithDelegate:self];
browser.displayActionButton = YES;
//show your photo whit url
[photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:#"http://Url.Photo.Here.jpg"]]];
[photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:#"http://http://Url.Photo.Here.jpg"]]];
[photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:#"http://http://Url.Photo.Here.jpg"]]];
[photos addObject:[MWPhoto photoWithURL:[NSURL URLWithString:#"http://http://Url.Photo.Here.jpg"]]];
// Do any additional setup after loading the view.
}
- (NSUInteger)numberOfPhotosInPhotoBrowser:(MWPhotoBrowser *)photoBrowser {
return _photos.count;
}
- (MWPhoto *)photoBrowser:(MWPhotoBrowser *)photoBrowser photoAtIndex:(NSUInteger)index {
if (index < _photos.count)
return [_photos objectAtIndex:index];
return nil;
}
- (void)segmentChange {
[self.tableView reloadData];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#end
That's all.
The github page worked great for me. They have a great tutorial. Here is the link: https://github.com/mwaterfall/MWPhotoBrowser
Please refer there Github
and also have look at DOC.
This might be helpful.
There are other Lib which can also help.
All of them are following same steps of zooming, scrolling, cache, etc.

How to justify text in a textbox ios?

I am developing an app for the iphone. One of my views contains a textbox that I used to display text. I used storyboard to do this. To better explain, this view will show the user the history of a football team. E.g " the team was established in 1990" etc and give a full history of the team. So there will be no user interaction. The reader will only read the text and move on to the next page. Is using a textbox for the text a good idea? And is there anyway to justify the alignment of the text so the ends of the lines are all alligned?
I think You will Use WebView Because justified aligment for text you only have center, left and right by UItextView.
IF You Want to Use UiWebView then set in
className.h
#interface className : UIViewController {
IBOutlet UIWebView *webviewName;
}
#property (nonatomic, retain) UIWebView *webviewName;
className.m
[webviewName loadHTMLString:[NSString stringWithFormat:#"<div align='justify'>%#<div>",TEXT_set] baseURL:nil];
UITextView is a good way to go, but it has no option to justify the text it contains. Another approach is using a UIWebView to display a simple HTML document.
To have nice looking justified text in HTML set the text-align property to justify and may use some JavaScript to enhance line-breaking.
Hope that helps :)
ok there is no problem with that u shoud to use textView ,just make sure its user intteraction is disable, while if ur data is coming dynamic than u should to use Web view, this make alignment correct
I have found that a generic view controller subclass to load a web view is very reusable. I have two. One designed for a navigation controller, and another designed a a modal view controller. I use them over and again with modification for things like help, legal information, and about my company. It would work very well for your purposes.
I use KempoZer as my free html editor to create the files I load in it. The advantage is that the html editor allows me to add bold, italic, headings, and different font sizes.
In storyboard I have several segues to the same view controller and set the two properties in a prepare for segue method in the view controller that calls the html view controller.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:#"instructions"]) {
[[segue destinationViewController] setNavigationTitle:#"Instructions"];
[[segue destinationViewController] setHtmlFileName:#""];
} else if ([[segue identifier] isEqualToString:#"legal"]) {
[[segue destinationViewController] setNavigationTitle:#"Legal Notices"];
[[segue destinationViewController] setHtmlFileName:#"legal.html"];
} else if ([[segue identifier] isEqualToString:#"about"]) {
[[segue destinationViewController] setNavigationTitle:#"About"];
[[segue destinationViewController] setHtmlFileName:#"AboutSuperDuperCoolApps.html"];
} else if ([[segue identifier] isEqualToString:#"videoTutorials"]) {
[[segue destinationViewController] setNavigationTitle:#"Video Tutorials"];
[[segue destinationViewController] setHtmlFileName:#""];
}
}
Here is the nab controller version, don't forget to create the storyboard view controller and hook up the web view.
// HTMLViewController.h
#import <UIKit/UIKit.h>
#interface HTMLViewController : UIViewController
#property (strong, nonatomic) IBOutlet UIWebView *webView;
#property (strong, nonatomic) NSString *htmlFileName;
#property (strong, nonatomic) NSString *navigationTitle;
#end
and
// HTMLViewController.
#import "HTMLViewController.h"
#implementation HTMLViewController
#synthesize webView, htmlFileName, navigationTitle;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
//
[self.navigationItem setTitle:navigationTitle];
// load selected html file
NSString *bundle = [[NSBundle mainBundle] bundlePath];
NSString *webPath = [bundle stringByAppendingPathComponent:htmlFileName];
[super viewDidLoad];
[webView loadRequest:[NSURLRequest requestWithURL:
[NSURL fileURLWithPath:webPath]]];
//
[super viewDidLoad];
}
- (void)viewDidUnload
{
[self setWebView:nil];
[self setHtmlFileName:nil];
[self setNavigationTitle:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#end

iPhone - UIActivityIndicatorView does not hide when stopped

I have a custom UIWebView written like this :
.h
#interface MiniWebViewController : UIViewController {
NSString* destinationURL;
UIWebView* webView;
UIActivityIndicatorView* activityIndicatorView;
}
#property (nonatomic, retain) NSString* destinationURL;
#property (nonatomic, retain) IBOutlet UIWebView* webView;
#property (nonatomic, retain) IBOutlet UIActivityIndicatorView* activityIndicatorView;
- (void) run;
#end
.m
#synthesize destinationURL;
#synthesize webView;
#synthesize activityIndicatorView;
- (id) initWithFrame:(CGRect)frame {
if (self = [super initWithNibName:#"MiniWebView" bundle:nil]) {
self.destinationURL = #"";
self.view.frame = frame;
self.activityIndicatorView.center = self.webView.center;
}
return self;
}
- (void) run {
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.destinationURL]]];
}
It is called an initied from another ViewController :
- (void) aFunction {
MiniWebViewController* oneViewController = [[MiniWebViewController alloc] initWithFrame:CGRectMake(/*Some Rect*/];
oneViewController.webView.tag = i;
oneViewController.destinationURL = /*SomeURL*/;
oneViewController.webView.delegate = self;
[self.view addSubview:oneViewController.view]; /* the Web view is inside this one */
[oneViewController run];
}
- (void) webViewDidFinishLoad:(UIWebView *)webView {
int webViewID = webView.tag;
MiniWebViewController* webViewController = [self.webViews objectAtIndex:webViewID];
[webViewController.activityIndicatorView stopAnimating];
}
- (void)webViewDidStartLoad:(UIWebView *)webView {
int webViewID = webView.tag;
MiniWebViewController* webViewController = [self.webViews objectAtIndex:webViewID];
[webViewController.activityIndicatorView startAnimating];
}
Into IB hidesWhenStopped is also checked. Everything is linked. The style of the indicator is set to "Large White" into IB.
When running, the indicator is not large, but small.
It is successfully started and stopped (delegate calls are triggered), but it doesn't hide when stopped.
What's the problem ? I don't see...
After a careful look in your code, you are modifying the UIActivityView in your init method. Change those so that they are in your viewDidLoad. At init, you view is not yet loaded, therefore, there is not an instance of those objects yet created in your controller.
These are the statement that need to be moved:
self.activityIndicatorView.hidesWhenStopped = YES;
self.view.frame = frame;
self.activityIndicatorView.center = self.webView.center;
This goes back to a fundamental of Objective-C: Sending a message to a nil object...returns nil. This is an annoying feature at times because there is no compile time warning, nor is there any runtime exception--a feature of the language.
Stupid I am, and XCode/cocoa really doesn't help.
I had loaded a wrong XIB name that DOES NOT exist.
So I ask to load something that does not exist, and the app stil works, even showing and using objects that does not exist. Untill one call does not work as expected. No crash...
It's nonsense.

How can I load a subview separately?

I have a MainView with a lot of subviews!
In one of that subview there is a WebView that check if there is a connection. The problem is that check connection ALWAYS at the startup of my app.. I want load this subview only when is opened...is that possible??
this is my code:
MainView.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#class VistaUno;
#class VistaDue;
#class Vistatre;
#class risposta;
#class VistaQuattro;
#interface MainView : UIView {
IBOutlet VistaUno *vistaUno;
IBOutlet VistaDue *vistaDue;
IBOutlet Vistatre *vistaTre;
IBOutlet risposta *Risposta; //this is the view that I want to load separately
IBOutlet VistaQuattro *vistaQuattro;
}
Risposta.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#class MainView;
#interface risposta : UIView <UIWebViewDelegate>{
IBOutlet MainView *mainView;
}
The Webview is loaded trouhg a UIViewController....
WebViewControllerRisposta.h
#import <UIKit/UIKit.h>
#interface WebViewControllerRisposta : UIViewController <UIWebViewDelegate>{
IBOutlet UIWebView *webview2;
IBOutlet UIActivityIndicatorView *m_activity;
}
#property (nonatomic, retain) UIActivityIndicatorView *m_activity;
#property (nonatomic, retain) UIWebView *webview2;
#end
WebViewControllerRisposta.m
#import "WebViewControllerRisposta.h"
#implementation WebViewControllerRisposta
- (void)viewDidLoad {
NSString *urlAddress = #"http://www.google.it";
NSURL *url = [NSURL URLWithString:urlAddress];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[webview2 loadRequest:requestObj];
}
#pragma mark UIWebView delegate methods
- (void)webViewDidStartLoad:(UIWebView *)webview2 {
m_activity.hidden= FALSE;
[m_activity startAnimating];
NSLog(#"Web View Did started loading...");
}
- (void)webViewDidFinishLoad:(UIWebView *)webview2 {
m_activity.hidden= TRUE;
[m_activity stopAnimating];
NSLog(#"Web View finish loading");
//Ricordarsi di aggiungere il codice per eliminare l'acquisto
}
- (void)webView:(UIWebView *)webview2 didFailLoadWithError:(NSError *)error {
[m_activity stopAnimating];
m_activity.hidden= TRUE;
NSLog(#"Error %i", error.code);
if (error.code == NSURLErrorCancelled) return; // this is Error -999
// error handling for "real" errors here
if (error != NULL) {
UIAlertView *errorAlert = [[UIAlertView alloc]
initWithTitle:#"NETWORK ERROR"
message:#"Sembra che al momento non vi è una connessione dati attiva! Per scaricare i nuovi Enigmi o inviare la tua risposta è necessaria una connessione Internet!"
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[errorAlert show];
[errorAlert release];
}
}
/*
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[webview2 dealloc];
[super dealloc];
}
#end
If the main purpose of your web view is to check for connectivity, rather use the Reachability class provided by Apple to check for connectivity. Look for the Reachability sample app
You have the request generated in the webview's, viewDidLoad method which is called whenever the view loads.
You have a design problem here. the MainView shouldn't have outlets to its subviews. As you have it now, all the views will load whenever your MainView object is instantiated from the nib. That is what generates the request when your app launches.
Instead, the outlets should be in your viewController(UIViewController) object that controls your `MainView'. The viewController should load the subviews individually from nib as they are needed.

iphone app with multiple views/subviews: memory is not being deallocated

I have an iPhone application that loads succesive views in a framework based on the one explained in this link (basically a main ViewController that loads/removes additional views with a displayView method). In my application I am using NIBs (the example link uses coded views) though so each of my ViewControllers has its accompanying nib.
Debugging in Instruments shows no leaks but if I enter/leave a section (ViewController with its View.xib), the nib remains in memory so after a few in/outs memory starts to accumulate.
I know the nib is not being unloaded because one is almost programmatically created (no stuff in IB) while another does have images and buttons created in IB. The large one is loaded first and the small one loads next. You would expect a reduction in allocation in Instruments.
How can I prevent this?
My structure is as follows, with a few comments below:
`MyAppDelegate.h`
#import <UIKit/UIKit.h>
#class RootViewController;
#interface MyAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
RootViewController *viewController;
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, retain) IBOutlet RootViewController *viewController;
-(void) displayView:(int)intNewView;
#end
`MyAppDelegate.m`
#import "MyAppDelegate.h"
#import "RootViewController.h"
#implementation MyAppDelegate
#synthesize window;
#synthesize viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[window addSubview:viewController.view];
[window makeKeyAndVisible];
return YES;
}
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
}
-(void) displayView:(int)intNewView {
[viewController displayView:intNewView];
}
- (void)dealloc {
[viewController release];
[window release];
[super dealloc];
}
#end
This controller handles subview load/removes:
`RootViewController.h`
#import <UIKit/UIKit.h>
#interface RootViewController : UIViewController {
}
- (void) displayView:(int)intNewView;
#end
`RootViewController.m`
#import "RootViewController.h"
#import "ViewController.h"
#implementation RootViewController
UIViewController *currentView;
- (void) displayView:(int)intNewView {
NSLog(#"%i", intNewView);
[currentView.view removeFromSuperview];
[currentView release];
switch (intNewView) {
case 1:
currentView = [[ViewController alloc] initWithNibName:#"View" bundle:nil];
break;
}
[self.view addSubview:currentView.view];
}
- (void)viewDidLoad {
currentView = [[ViewController alloc]
initWithNibName:#"View" bundle:nil];
[self.view addSubview:currentView.view];
[super viewDidLoad];
}
- (void)dealloc {
[currentView release];
[super dealloc];
}
#end
There would be as many case as "detail" ViewControllers I have (right now I have 3 case but this will grow to 10 or more). The purpose of this structure is to easily move from one "section" of the application to another (NavBar controller or TabBar controller do not suit my specific needs).
`ViewController.h`
// Generic View Controller Example
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController {
UIImageView *_image1;
UIImageView *_image2;
NSTimer *_theTimer;
}
#property (nonatomic, retain) IBOutlet UIImageView *image1;
#property (nonatomic, retain) IBOutlet UIImageView *image2;
#property (nonatomic, retain) NSTimer *theTimer;
#end
`ViewController.m`
#import "ViewController.h"
#import "MyAppDelegate.h"
#synthesize image1 = _image1, image2 = _image2, theTimer = _theTimer;
- (void)loadMenu {
[self.theTimer invalidate];
self.theTimer = nil;
MyAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
[appDelegate displayView:2];
}
-(void)setView:(UIView*)aView {
if (!aView){
self.image1 = nil;
self.image2 = nil;
}
[super setView:aView];
}
- (void)viewDidLoad {
//some code
[super viewDidLoad];
}
- (void)viewDidUnload {
self.image1 = nil;
self.image2 = nil;
}
- (void)dealloc {
NSLog(#"dealloc called");
[self.theTimer invalidate];
[self.theTimer release];
[self.image1 release];
[self.image2 release];
[super dealloc];
}
Notice the NSLog in dealloc. This is being called (I can see it in the console) but the memory needed for the nib is not freed (Instruments shows an increase in memory allocation when leaving a section, because a new nib is loaded).
Any help will be greatly appreciated. I have tried a million different things and I cannot get the nibs to unload.
After a million different tries I finally ran into this forum.
It states:
Apparently images assigned in IB are loaded into image views using imageNamed. imageNamed caches the images in a way that makes them unloadable. You could load the images in viewDidLoad with initWithContentsOfFile and then assign them to the views.
Somewhere else I had read that imageNamed is the devil so I'd rather not have my images load that way.
(BTW this is iPhone OS 3.1 I'm using)
What I ended up is leaving the UIImageView intact in IB but with an empty .image value. The modified code is something like:
- (void)viewDidLoad {
NSString *path = [NSString stringWithFormat:#"%#/%#", [[NSBundle mainBundle] resourcePath], #"myImageThatBeforeWasAValueinIB.jpg"];
UIImage *image = [UIImage imageWithContentsOfFile:path];
outlet.image = image;
// do the rest of my stuff as it was
[super viewDidLoad];
}
- (void)dealloc {
outlet.image = nil;
[outlet release], outlet = nil;
[super dealloc];
}
And now everything works like a charm! Memory is recovered when I unload a nib and when I get memory warnings.
So pretty much if you have IBOutlets for UIImageViews and memory is a concern (it always is I guess), you can design all you want in IB and when the time comes to connect them to outlets, remove the image reference in IB and create it from code. IB is really good for laying out your app. It would suck to have to do all that thing by code, but I also found this nice utility that converts nibs to objective c code although I haven't tested it yet.
Did you try setting your outlet variables to nil in dealloc?
You are correctly implementing the setView method, but you are setting your outlet variables to nil in the viewDidUnload method instead of dealloc. As discussed here, you should implement dealloc as follows:
- (void)setView:(UIView *)aView {
if (!aView) { // view is being set to nil
// set outlets to nil, e.g.
self.anOutlet = nil;
}
// Invoke super's implementation last
[super setView:aView];
}
- (void)dealloc {
// release outlets and set outlet variables to nil
[anOutlet release], anOutlet = nil;
[super dealloc];
}
EDIT: if the outlets are UIImageViews, then it may be the case that you need to do
anOutlet.image = nil;
because setting the UIImage’s instance image property should increase the retain count of the UIImage’s instance by 1.