Div
Div

Reputation: 179

How to reload the UIViewController

Can anyone please tell me how to reload the view.In my program,it contain a tab view controller.There is one item named "A" in the tab.And this "A" item is pointing to a viewController.In that view Controller, it is displaying some datas and I have included UIActionSheet in that. There is one button-Delete in the actionsheet.This delete button is for deleting the particular data.Now my problem is that I need to reload that view so that these deleted data should not be displayed. So anyone please tell me how to reload the page. I have included the following code before

[self presentModalViewController:historyView animated:YES];
[historyView setNeedsDisplay];

but it is showing some error :-

 No visible @interface for viewcontroller declares the selector 'setNeedsDisplay'

Please tell me the solution.. :(

Upvotes: 3

Views: 2298

Answers (1)

RomanN
RomanN

Reputation: 2087

UIViewController class doesn't have a method setNeedsDisplay. The UIView class does have this method. So you can write like that:

[historyView.view setNeedsDisplay];

But this method doesn't reload a view. It just marks the receiver’s entire bounds rectangle as needing to be redrawn (from apple documentation iOS Developer Library). So as a result the drawRect method will be called.

To solve your problem you can create your own function like initializeUI in your view controller and then call it when the view is loaded initially (in viewDidLoad method) and for example after deleting the data when you need the view to be updated.

Upvotes: 6

Related Questions