I’m currently working on an iPad app and would like to make a function call to my view controller to switch views on the event that an object is moved to a certain location. In “touchesMoved” and “touchesEnded” I’ve tried to call a function in my view controller to switch views if an object is dragged to a certain location, but the function never seems to get called.
For example, “touchesEnded” is fairly simple and just makes the call to the view controller, the message gets logged inside of touchesEnded but not inside of the view controller’s function that should be getting called. I tried stepping into the function in the debugger, but it seems to just step over it.
From the View *Note m_pJupiter is a UIImageView, m_pLevelID is an NSString, and m_pMyVC is an instance of my custom view controller class.
- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if (m_pJupiter.center.x >= (m_pDest.center.x - 25))
{
NSLog(@"Calling beginGameWithLevelID");
[m_pMyVC startGameWithLevelID: m_pLevelID];
}
}
The View Controller’s Function
- (void) startGameWithLevelID:(NSString*)pLevelID
{
NSLog(@"MyViewController - beginGameWithLevelID");
// The logic for switching views, etc
}
The first log message always shows up, but the one in the view controller never does. I’m thinking worse come to worst I’ll just use a custom UISlider, but this has been vexing me nevertheless.
if the output is only “111”, indicate that it can not find your “- (void) startGameWithLevelID:(NSString*)pLevelID” method
if the output is “111” “222” , maybe your xcode has some problem , reopen it