Reputation: 300
i want to reload ViewdidLoad in a method But now want to call again like [self viewDidLoad ];
is this possible?
Upvotes: 10
Views: 18832
Reputation: 40008
Instead of calling viewDidLoad:
make another method (newMethod
) and move all the code in it that needs to be called then from
- (void)viewDidLoad{
[super viewDidLoad];
[self newMethod];
}
Then from your code where you want to call viewDidLoad:
call
[self newMethod];
func viewDidLoad() {
super.viewDidLoad()
self.newMethod()
}
Then from your code where you want to call viewDidLoad:
call
self.newMethod()
Upvotes: 31
Reputation: 851
Yes you can call from any method but if you post your scenario then it is better to reply
[self viewDidLoad];
Upvotes: 1
Reputation: 2218
Copy all code in - (void)viewDidLoad then paste in viewWillAppear
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//paste your viewDidLoad codes
}
Upvotes: 3