Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 3    Views: 47

Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
09/04/14 11:53 AM (9 years ago)

Where is best to put my code?

I have a whole app created with the Ultimate screen creator (one of the best plugins on the market IMO) on a couple of the screens, i want to play an audio file when the screen loads. I have the code and it all works and i have placed the code right at the end of the viewDidLoad. However, although it works, the audio starts playing before the screens fully loaded. Is there a better place to put this code so i know the screen is fully loaded before starting the audio? Thanks
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
09/04/14 12:06 PM (9 years ago)
Place it in the viewDidAppear method. That fires after the view comes on the screen. Might have to create the method if it's not already in there. Start type -(void)viewDidAppear and Xcode will fill in the rest.
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
09/05/14 06:52 AM (9 years ago)
Thanks Chris, I created -(void)viewDidAppear { //My Code } after -(void)viewWillAppear { //Your code } it doesn't seem to play the audio at all, but if i copy it back to the end of the viewDidLoad, it does.... any ideas? Thanks
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
09/05/14 07:10 AM (9 years ago)
ok, i got it working when i changed it to -(void)viewDidAppear:(BOOL)animated { Thanks
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.