Samina Shaikh
Samina Shaikh

Reputation: 300

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?

Upvotes: 10

Views: 18832

Answers (3)

Inder Kumar Rathore
Inder Kumar Rathore

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

Swift version

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

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

self.newMethod()

Upvotes: 31

Muzamil Hassan
Muzamil Hassan

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

Ravi Kumar Karunanithi
Ravi Kumar Karunanithi

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

Related Questions