In my SecondView has accelerometer objects and also have some removeFromSuperview, and when I enter the SecondView from MainView again, the removeFromSuperview objects are not there anymore. I need a refresh thing to make all the objects start all over again on SecondView.

In my SecondView has accelerometer objects and also have some removeFromSuperview, and when I enter the SecondView from MainView again, the removeFromSuperview objects are not there anymore. I need a refresh thing to make all the objects start all over again on SecondView.

reloadData is for UITableViews, which u probably don't have.
u need something like this
[self.view setNeedsDisplay];
or
[self.view setNeedsLayout];

Click to expand...

hi jnoxx,

I already added the line that you mentioned. But I'm not sure why it exits the apps when I press the "enter" button on Main page. I put the code on my "enter" button. "secondView" is my second page. And goes like this:

The usual meaning of that warning is that the specified parameter isn't of the type that is found in the prototype. So if the prototype calls for an NSString* and the actual type of the parameter is a NSDictionary* you would get the warning.

You should always fix this warning. Occasionally you would fix it with a typecast but usually it indicates that you've made an error.

setNeedsDisplay is a UIView method. If your secondView is a view controller then it won't respond to that method, hence the warning.

You haven't explained this problem very well. What kinds of views need to be redisplayed? Standard controls won't do anything useful with setNeedsDisplay. It's a red herring. Obviously view controllers will just crash if you send them a message they don't implement.

Try to explain in more detail what is supposed to happen. What is the view hierarchy? What is happening? What kinds of views are supposed to reload their info?

setNeedsDisplay is a UIView method. If your secondView is a view controller then it won't respond to that method, hence the warning.

You haven't explained this problem very well. What kinds of views need to be redisplayed? Standard controls won't do anything useful with setNeedsDisplay. It's a red herring. Obviously view controllers will just crash if you send them a message they don't implement.

Try to explain in more detail what is supposed to happen. What is the view hierarchy? What is happening? What kinds of views are supposed to reload their info?

Click to expand...

Hi PhoneyDeveloper,

By looking at my SecondView.h file as follow, I think it's using view controller

The program goes like this:
1st view: I have a ENTER button(UIButton/round rect button) which enters the second view.

2nd view: Contains an accelerometer ball to touch two objects(when it touches the box, it will remove the box from superview). One BACK button(UIBarButtonItem) and one START button(UIBarButtonItem). When press start then it loads the accelerometer function to let the ball moves.

If I didn't refresh it, when I click BACK to 1st view then ENTER to 2nd view again. The 2nd view still remains the same, I would like the 2nd view back to the beginning where I click on the START button then it moves, later on I wanna add SCORE also to record scores, then if I BACK to 1st then ENTER 2nd view, the score will reset zero again, just everything start all over again on 2nd view.

Just now I tried to put this, all succeeded but nothing happens on 2nd view:

[NOTE: This code is oversimplified and doesn't deal with leaking of secondView, etc.]

This will ensure that when your second view is presented, it's all fresh and in a "start" state.

And perhaps you could explain the reason for secondView being an IBOutlet-connected instance variable in your TwoViewAppViewController.

P.S. As a hint for your understanding of the classes you've setup, you might want to consider renaming SecondView (which might be mistaken for a UIView subclass) as SecondViewController instead. Such a naming convention is fairly common in iPhone dev.

[NOTE: This code is oversimplified and doesn't deal with leaking of secondView, etc.]

This will ensure that when your second view is presented, it's all fresh and in a "start" state.

And perhaps you could explain the reason for secondView being an IBOutlet-connected instance variable in your TwoViewAppViewController.

P.S. As a hint for your understanding of the classes you've setup, you might want to consider renaming SecondView (which might be mistaken for a UIView subclass) as SecondViewController instead. Such a naming convention is fairly common in iPhone dev.

Click to expand...

Hi dejo,

Actually these codes and the naming I followed a tutorial from YouTube video.

I thought I have secondView being an IBOutlet-connected instance variable in my TwoViewAppViewController is to link to secondView? If I didn't put it says undeclared.

As you said, now I already changed all the names "SecondView" to "SecondViewController", including the header names and etc.

No, I don't mean create another empty UIView. Does your SecondViewController have an associated UIView? That is, did you specify the option "With XIB for user interface" when creating it?

Click to expand...

Yes, I don't know why in the video tutorial above each UIView has viewController.

I don't know how to specify "with XIB for user interface" actually, I see him just drag the viewController, then drag the UIView. Meaning first view has a viewController and a UIView, second view has a viewController and a UIView.

Sorry newbie80, I don't think I can help you further with this. I'm not sure how to instantiate a fresh view controller when the original was done via IB. Hope you find your answer though.

Click to expand...

Hi Dejo,

It's okay, I know you already did your best to help me. Thank you, really appreciate your help and other here. And after I discussed with my colleague, the only way to do is to remove everything on second view and re-assign their position again on the second view. Almost completed my apps already, you helped me a lot in progress and I've learnt something new from you. Thanks again. See ya, problem solved

MacRumors attracts a broad audience
of both consumers and professionals interested in
the latest technologies and products. We also boast an active community focused on
purchasing decisions and technical aspects of the iPhone, iPod, iPad, and Mac platforms.