CCTableView action on cell button stop working after scroll - cocos2d-iphone

I have a problem with CCTableView. I give an action on the cell.button and it works but, after scrolling a bit, the action is no more fired.
I use
[cell.button setTarget:self selector:#selector(onMyButtonClicked:)];
Anyone has an idear on this ?
Thanks.

Ok I forgot to put [super onEnter]; in the onEnter function.
Now everything is fine.

Related

UIButton not getting focus

I have my code in Swift 3. I have two UITextFields and a UIButton in my view. I have the textFieldShouldEndEditing delegate of the first UITextField which is fired when I focus on the 2nd UITextField. However when I tap on the UIButton this delegate is not fired. I had thought that when a UIButton gets focus then the UITextField’s event will automatically fire since it is losing focus. However, when I tap on the UIButton, the cursor is still blinking in the UITextField, which means it is not losing focus.
Any ideas on why the UIButton is not getting focus will be most appreciated.
Thanks.
This is an infuriating aspect of developing forms on iOS. Button taps don't remove focus from UITextField / UITextView the same way they would in an HTML form.
I'm sure there are more elegant ways to solve this, but if I want to consistently do this across all forms I ensure that the following line of code is run when users tap on any buttons of mine.
- (void)userDidTapButton:(id)sender
{
[[[UITextField new] becomeFirstResponder] resignFirstResponder]
// the above embarrassing line of code basically creates a new textfield
// puts focus in it (thereby removing focus from any existing textfields
// and then removes focus again
// this ensures that delegate events fire on your existing textfields
// finally, run any other button code
}

CWnd::SetRedraw(False) make mouse go throught window

So I have a MFC application which flick when we do some action.
So I figured I would set SetRedraw(false) and set it to true at the end of the function.
The application doesn't refresh anymore but if I click on it while SetRedraw(false), my cursor is not catched by my application, it goes throught it and set focus on the application below.
Anyone has some kind of idea how I could fix that.
I ended up using CWnd::LockWindowUpdate instead after some research.
It freezes the update but doesn't act if the window was transparent.

cocos2dx OpenGL error 0x0506 when dismissing UIViewController

I've run into very difficult issue. In the Cocos2d-x game i'm working upon currently (it's main part is written by another developer i'm just finishing it, and by now it is supposed to work on iOS only so i don't care about all the Android related stuff ) i need to use UIViewController. I present it and dismiss in a very usual way:
present:
SDMoreAppsViewController *vc = [[SDMoreAppsViewController new] autorelease];
[viewController presentViewController:vc animated:NO completion:nil];// viewController is UIWindow root view controller
dismiss:
UIViewController *controller = self.presentingViewController;
[controller dismissViewControllerAnimated:NO completion:nil];
Once the view controller is successfully dismissed i see the message in my console telling me that opengl error 0x0506 has appeared. This message is printed from methods swapBuffers of EAGLView and draw of CCSprite. Along with this message my whole scene becomes unresponsive. Tapping buttons gives no result.
I've tried a lot of things already. I tried pushing my view controller and adding it as a child instead of presenting but it doesn't even shows the view controller (viewWillAppear method doesn't get called), i also tried adding its view as a subview to my app's window but that also brings a lot of different errors.
I'm using cocos2d-x version cocos2d-2.1rc0-x-2.1.3.
Did someone solve such a problem before? Any suggestions?
before presentViewController, pause rendering:
CCDirector::sharedDirector()->pause();
CCDirector::sharedDirector()->stopAnimation();
call resume and startAnimation in completion block

C++ Win32 How to Create a "toggle" Pushbutton

I was originally thinking this would be extremely easy to do. Google searches returned results for everything but this.
I am trying to have a normal button that I can click, and it stays down, click again, and it rises back up.
I found one function that did what I wanted, but only worked if the button retained focus, click anywhere else and it rises again.
Button_SetState(GetDlgItem(hwnd, IDC_BTN_SLEEPCLICK), TRUE);
Is there any real way to do this? Or am I gonna need to do this kind of thing by hand?
Thanks.
Create a check box, then set the "push like" property for that check box to true.
You want a checkbox with BS_PUSHLIKE style. To toggle it programmatically, use Button_SetCheck
The "staying down" and "rising back up" are a matter of how you draw the button.
You could create your own button class by using the Paint and Redraw methods.

How can refresh UIView in UITabBarController?

I'm stack on refreshing view in TabBar. The UIView is read only first time I pressed the TabButton and does not "viewDidLoad" next time. I want to refresh UITableView every time I pressed the button.
Thank you!
Ok Found a solution (just right after i posted this here)
add:
- (void)viewWillAppear:(BOOL)animated
{
NSLog(#"View appears");
}
to your ViewController and you will see that this method will be called, by clicking the TabButton ;)