Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to Reaload viewDidLoad in a method , Not call again such as [self viewDidLoad ];

i want to reload ViewdidLoad in a method But now want to call again like [self viewDidLoad ];

is this possible?

like image 865
Samina Shaikh Avatar asked Mar 26 '12 06:03

Samina Shaikh


3 Answers

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];

Swift version

func viewDidLoad() {
    super.viewDidLoad()
    self.newMethod()
}

Then from your code where you want to call viewDidLoad: call

self.newMethod()
like image 189
Inder Kumar Rathore Avatar answered Nov 12 '22 12:11

Inder Kumar Rathore


Copy all code in - (void)viewDidLoad then paste in viewWillAppear

- (void)viewWillAppear:(BOOL)animated 
{
  [super viewWillAppear:animated];
  //paste your viewDidLoad codes
}
like image 23
Ravi Kumar Karunanithi Avatar answered Nov 12 '22 12:11

Ravi Kumar Karunanithi


Yes you can call from any method but if you post your scenario then it is better to reply

[self viewDidLoad];
like image 1
Muzamil Hassan Avatar answered Nov 12 '22 11:11

Muzamil Hassan