|
|
#1 |
|
Simulate memory warning not working
I have a UITabBarController containing two view controllers.
The purpose of an exercise I am following is to demonstrate that you should never reference a view controller's view in the initialiser of a view controller. To demonstrate the point, I am asked to add the following code to the view controller's initWithNibName method: Code:
-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nil bundle:nil];
if (self) {
UITabBarItem *tbi = [self tabBarItem];
[tbi setTitle:@"Time"];
UIImage *i = [UIImage imageNamed:@"Time"];
[tbi setImage:i];
//This is the offending line
[[self view] setBackgroundColor:[UIColor greenColor]];
}
return self;
}
However, when I do this the viewController's view doesn't seem to get destroyed because the background is still green. I am also directed to override the viewDidUnload method, and in here an NSLog instruction is supposed to write something to the console. However, it never does, which indicates that viewDidUnload is never getting called. For information, the memory warning simulation does seem to do something because "Received memory warning" appears in the console. Does anyone know why this is, please? I am fairly confident I've followed the book to the letter. Could it be something to do with iOS 6? The book was written when iOS 5 was the latest OS version. I can't seem to test this theory in the simulator because I inadvertently built the app as an iOS 6 app, and the new layout constraints that appear as part of building the XIB file cause the iOS 5 simulator to crash. Thank you.
__________________
13" Macbook Pro, 2.4 GHz, 8 GB RAM; 16GB iPhone 5, 32GB iPad 3 Last edited by MickeyT; Feb 2, 2013 at 06:37 AM. |
|
|
|
0
|
|
|
#2 |
|
I've helped myself here....I must have been looking at the book when I typed this out the first time and missed the popup in the attached screenshot.
Please consider this one resolved.
__________________
13" Macbook Pro, 2.4 GHz, 8 GB RAM; 16GB iPhone 5, 32GB iPad 3 |
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 07:45 AM.






Linear Mode
