Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use viewDidLoad method in UITableviewCell?

Tags:

ios

iphone

Can I use viewDidLoad method in UITableviewCell?

like image 610
user5457 Avatar asked May 14 '12 06:05

user5457


People also ask

Does viewWillAppear get called before viewDidLoad?

viewWillAppear(_:)Always called after viewDidLoad (for obvious reasons, if you think about it), and just before the view appears on the screen to the user, viewWillAppear is called.

Is viewDidLoad only called once?

viewDidLoad method is called only once in ViewController lifecycle. The reason retrieveMessage() is called in viewDidLoad because it's adding observer to start listening for received and sent message.

Can viewDidLoad be called multiple times?

-viewDidLoad will be called once whenever the view controller needs to load its view hierarchy. Obviously, that'll happen the first time that the controller accesses its view. If the view controller later unloads its view, then -viewDidLoad will be called again the next time the view is loaded.

How many times does viewDidLoad get called?

viewDidLoad() is one of the initialization methods that is called on the initial view controller. viewDidLoad() is called before anything is shown to the user - and it is called only once.


1 Answers

No you don't write viewDidLoad in Custom cell class subclassing UITableViewCell(It;s part of UIViewController) .you have a method called

-(void)layoutSubviews {     [super layoutSubviews]; } 

where in you can define frames and all for custom cell's controls.Refer Apple's UITableviewCell reference

Note however that 'viewDidLoad' is called only once in the lifetime of the object; it is rather like an initializer in general OO programming. However, 'layoutSubviews' will be called many times on each cell (depending on issues like scrolling and so on). It's important to realize that for this reson many of the things you "usually do" in viewDidLoad, you can not do in layoutSubviews.

Note that viewDidLoad is called once only: layoutSubviews is called often.

It will just be a simple function if you write it.

Tutorial for custom cell

like image 55
Abhishek Singh Avatar answered Oct 14 '22 17:10

Abhishek Singh