user1142134
user1142134

Reputation: 75

Is there a method in iOS that can reload the current View?

My problem is:

I have a view to show some comments. When the view showed first time, every subview will adjust there position or hide status according to comments' count or other terms.

Also, users can post a comment at the same view, so after the comment committed, every subview should adjust there position or status according to the new comments' total count.

I can configure all the subviews that needs to change position after post connection.But that's a lot of work to do and very easy to make mistake.

However, if I can let the view reload it self(more or less like call viewWillAppear and viewDidLoad again,but reset every view), and just run the method in viewDidLoad, that will be much easier to refresh the comments.

So I don't know if there's a method that can reset all the subviews to origin position. I have tried the [self setNeedsLayout] and [self setNeedsDisplay] method but won't work;

Is there a method in IOS that can reload the current View?

Image

Upvotes: 1

Views: 1107

Answers (1)

Maksim
Maksim

Reputation: 2052

There is now way to update data in your subviews automatically "reloading" your view. You can update all subviews by assigning new values to them manually (via IBOutlets), distinguishing subviews by their tags, but that is not really good practice.

The much better approach to make a view with comments is to use custom view based on UITableView with individual cells representing comments.

For example, check how it is done in this class - http://alexbarinov.github.io/UIBubbleTableView/

Upvotes: 2

Related Questions