Release Event Handler? - ios

Maybe I'm just over thinking this, but is there a way to capture when the user let's go of a button with iOS? So to pose my question better: I have a button on the screen, and when the user let's go of it, I want to call an event. Is there a way to do that?

Try to answer, I wonder the same idea too..
From Apple Document : UIControl Class
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIControl_Class/Reference/Reference.html
My Idea sub-class UI Control using following Task :
– beginTrackingWithTouch:withEvent:
– continueTrackingWithTouch:withEvent:
– endTrackingWithTouch:withEvent:
– cancelTrackingWithEvent:
Put a BOOL isBegin = YES at beginTrackingWithTouch to know that it was touched..
Then when endTrackingWithTouch happen (which is the user end touching the control), do what you going to do in there then set isBegin back to NO
regards,
FHW

Related

Appirater doesn't work

I'd like to show Appirater when I click some button.
here is my setting in appdelegate
Appirater.setAppId("...")
Appirater.setDaysUntilPrompt(0)
Appirater.setUsesUntilPrompt(0)
Appirater.setTimeBeforeReminding(30)
Appirater.setSignificantEventsUntilPrompt(10)
Appirater.userDidSignificantEvent(true))
Appirater.appLaunched(true)
and then I put below code in my view controller
Appirater.tryToShowPrompt()
I don't any idea how to call correct method in action.
You will be able to use forceShowPrompt method. However by forcing the prompt consider the side effects. By the way if you want to see the Appirater on the debug mode always, you can use Appirater.setDebug(true) method.

UITextField can send its action twice. Is this an iOS bug, or did I make an error?

In iOS, I have a UITextField in a UITableViewController scene that is governed by a Navigation Controller. All static cells. The text field has the "Clear on editing" flag switched on. I want to get and save the value entered in the field, so I have the -editingDidEnd: action call my saveData: method in the custom UITableViewController subclass. If I click out of the text field, all is well. However, if I back out of the scene using the Back navigation button, then saveData: gets called twice. Once with the entered value, and a second time with an empty value. This appears to be incorrect behavior.
I've made a demo project and posted it to GitHub here: https://github.com/davehirsch/BugDemo
Am I doing something wrong? Is this an iOS bug? It seems unlikely that it's a bug nobody else has found (and I've looked around for others reporting similar things). I'm running the latest non-beta versions of Xcode and OS X, and the bug is happening in the iOS Simulator (but I'm not sure if it would happen on a real device, I guess).
Yes you are right. It looks like a bug in UINavigationController.
Before and after animation the method [UITextField resignFirstResponder] is called before and after animation. The first call is done by [UINavigationController popViewControllerAnimated:], and the second one in [UINavigationConteoller navigationTransitionView:didEndTransition:fromView:toView:] that call [UIView(Hierarchy) _removeFirstResponderFromSubtree].
Looks like your text field hasn't resigned yet as a first responder before animation ends.
[EDIT]
I recommend to look at rdelmar comment.

iOS5 Custom Window rotation issue

So I'm creating and showing a custom window in my iOS app because I'm writing a dynamic alert view that also functions like a growl/toast alert. It works AWESOMELY in ios6 (Hopefully I can open source this baby and you can all check it out)
But anyway, when I run this in ios5, the window that my alerts exist on doesn't seem to rotate with the device/simulator. No matter what, my custom window stays in portrait mode.
The UIWindow is just a UIView subclass, so there's no nice 'shouldRotate' delegate method.
I'm kinda stumped on why this is happening in ios5 but not 6. Any help would be GREATLY appreciated ^_^
My window has a rootviewcontroller, which I completely forgot about. I just needed to implement
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return YES;
}
To get it to work.
:-D
It's usually not recommended two use multiple instances of UIWindow in one iOS app. The only valid reason to do so is to support external screens. You should use a UIView instead, ideally managed by a UIViewController.
I assume, (since you didn't provide any code, I can only assume) the reason why your window doesn't 'rotate' is, that it's simply not getting any notifications about device rotation. Only the keyWindow receives them by default.
I would highly recommend to redesign your app to use a properly managed UIView instead. If you desperately don't want that for some reason, you would have to register your instance of UIWindow to receive the UIDeviceOrientationDidChangeNotification and then (in the handler) evaluate what the new orientation is and change the window's frame accordingly (plus maybe other things that need to be done in response to the orientation change)

Can I disable multitouch for a Windows Phone Application?

I'm currently working on a game for Windows Phone 7, using the XNA version of Cocos2d.
Due to the rules of the game, I need it so that the user can only touch one thing at a time but multitouch seems to be always in effect. Additionally I don't know if this is a Cocos error, but it also causes the game to behave erratically (responding to a single touch like they were many).
I guess I would have to correct every touch event of the game one by one, but I was wondering if I can use something to disable multitouch quickly, or reduce the number of touches accepted to one at a time.
I'm not sure about Cocos2d-x for XNA. But in regular XNA if you want to force only single-touch input, the simplest way to that is by using the Mouse class. In a touch environment it is still available - emulated by using touches. It only responds to a single touch at a time.
Each frame you can get the list of touches. Since their management is delegated to your code, just ignore them if you have more than one. Another option is only using the first one, remember its TouchID and ignore all the rest.
I've used the first option when porting mouse applications over to the phone.
Cocos touch input has to be treated somewhere in the game, in accessible code, so you should have access to their point of entry.
Yes, you can do this with Cocos2D-XNA. You set the TouchMode to be either OneByOne, or AllAtOnce. OneByOne will give you the single CCTouch signature methods, and AllAtOnce will get you the List signature methods.
public MyCtor() {
TouchEnabled = true;
TouchMode = CCTouchMode.OneByOne;
}
public override bool TouchBegan(CCTouch t) {
}
public override void TouchMoved(CCTouch t) {
}
public override void TouchEnded(CCTouch t) {
}
Now you only get one touch at a time. There's no way to disable the touch pad's delivery of all touches from all fingers though. As another user mentioned, you would just ignore those.
Remember that you get a touch ID with every touch, which works to match the touch data with each began, moved, ended event call. I suggest you make use of touch ID as well to ensure that you are processing only the touches that you want.

Is there focus and lost-focus event on black berry sdk?

I am very new developer for black berry environment. Is there a focus and lost-focus event for the controls which are currently selected or deselected?
Please give me some like or example.
Thank you.
If you are writing your own custom field, or want to catch the events of your Screen class(es), then you would override the virtual Field.onFocus() and Field.onUnfocus() methods.
If you want to catch focus events of other fields, then you have to implement the FocusChangeListener interface and then call the Field.setFocusChangeListener() method of those fields.
Yes, these are Field.onFocus(int direction) and Field.onUnfocus(). Check the API for details.

Resources