Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MythicFrost

macrumors 68040
Original poster
Mar 11, 2009
3,944
40
Australia
Alright basically I have a very simple task:
Show my Default.png image on my UIImageView, add it to my current view, run a function after 3 seconds that removes the UIImageView from my current view and releases it.

I have several issues though, the first being more important, I can't access ivSplash in the dismissSplashScreen function, since it's declared (as a local variable) in the viewDidLoad function.
Normally, I'd just declare the variable outside of the function but I've tried this in objective c but that doesn't really work properly (at least the way I do it).

This is the code:
Code:
- (void)viewDidLoad {
	[super viewDidLoad];
	UIImageView *ivSplash = [[UIImageView alloc] initWithImage:([UIImage imageNamed:(@"Default.png")])];
	[[self view] addSubview:(ivSplash)];
	[self performSelector:@selector(dismissSplashScreen) withObject:nil afterDelay:3.0];
}
//Functions
- (void)dismissSplashScreen {
	//I want to remove the UIImageView from my view
	//Then I will release it from memory? [ivSplash release];
}
Basically I want to get rid of the splash screen because I do not need it anymore. Any idea's? Thanks.
 
I'm still in XCode 101 myself, but instead of declaring your splash view as local to a function, declare it as a local variable for the object, and then clean it up with a timer.
 
declare it as a local variable for the object
I'm not sure what that means
and then clean it up with a timer.
Wouldn't I encounter the same problem not being able to access it?

Thanks for your reply.

EDIT: lol I just declared UIImageView *ivSplash; in my header file and now it works in .m just how I want, that's fantastic!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.