Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialChee Mervin
Courses Plus Student 4,195 PointsCGRectMake implementation in viewDidLoad and viewDidAppear.
Hi guys, still a bit unsure
Just want to check with you guys, I'm still unsure why I am able to put
self.showQuote.frame = CGRectMake(100, 250, 280, 44);
in the viewDidLoad section of the code challenge and get it right.
As the video for this topic mentioned that having the CGRectMake(x,y,width,height) in the viewDidLoad section would not work as it would load the (x,y,width,height) directly from the storyboard instead. Hence the CGRectMake has to be implemented under a viewDidAppear.
Or are there certain exceptions in coding CGRectMake that I'm not aware of here? Thanks!
Cheers!
- mervin
2 Answers
Fred Lawton
5,904 PointsI don't recall the video, but I'm not sure why it would behave as you say the video described.
Maybe the following will help. Look at Figure 4-1 in this link: https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/ViewLoadingandUnloading/ViewLoadingandUnloading.html
It looks like the loadView method is called if there is not a view in memory when a view property is accessed. Then either the storyboard or a custom loadView method is used to load information. After this the viewDidLoad is called.
After viewDidLoad is called, viewWillAppear is called. Hopefully this pic is accurate: http://stackoverflow.com/questions/5562938/looking-to-understand-the-ios-uiviewcontroller-lifecycle.
Notice in the pic, if the view already exists in memory, then viewDidLoad is not called and the process goes to viewDidAppear.
Chee Mervin
Courses Plus Student 4,195 PointsAh that clears it up, thanks Fred!. =)
Cheers
- mervin