Drag UIButton on long press in iPhone - iphone

I am new in iPhone development.
I want to create one application in which whenever user long presses the button, it will be shaken and user is able to drag it on the screen and he will also be able to change its location.
I have tried this code.
- (void)handleLongPress:(UILongPressGestureRecognizer*)sender
{
NSLog(#"Long press called!!!!");
}

Check out the MoveMe sample app. It will show you how to allow movement of subviews by touch and drag.
http://developer.apple.com/library/ios/#samplecode/MoveMe/Introduction/Intro.html
you can also download that sample code ... :)

Related

iphone home button event

I am developing a iPhone application and would need to track the home button pressed event by user while the app is in background mode.I have go through the apple documentation/apis but could not find out any to track.
It would be great if anyone can help me on this to track the iPhone home button pressed event.
Your application can't catch any events while in the background. There are some special cases which allows your app to do some tasks in the background, but even them wouldn't allow you to listen to Home button interaction.
You cann't track the home button pressed or not but as your situation is to see if application went in background or not. for this there is a method applicationDidEnterBackground:(UIApplication *)application. This method is called as the application enters into background.
- (void)applicationDidEnterBackground:(UIApplication *)application
{
NSLog(#"Application Entered Into Background.");
}

How to do orientations in iphone?

I have a Setting page which contains setting functions of the application,there is a button called lock-rotation button,by default my application supports all the orientations,but my need is i want to set lock the rotation in my lock-rotation button,if the user tap the lock-rotation button it popups two button lock horizontally and lock vertically,if the user tap any one of this button it automatically stops the rotation of the corresponding orientation .How to do this?
Thanks in advance.
Sorry to say, but i dont think so that we can lock the orientations in iphone on Button Tap...Have you seen any App which does this orientation controlling... if yes plz do tell to me... Thanks
you try these methods for controlling the orientations...
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
}
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
}

OpenFlow AFItem UIImageView touchesBegan

I'm trying to use the OpenFlow project inside of my application.
My target is; when the user tab to any flow item which currently UIImageView according to OpenFlow's AFItemView, it will be zoom-in in the screen (with/without animation) and then user will be able to close and get back to cower flow view in the app.
I didn't get the tocuhesBegan event when I used the default OpenFlow library, then I saw this line
self.multipleTouchEnabled = NO;
self.userInteractionEnabled = NO;
self.autoresizesSubviews = YES;
in the AFOpenFlowView.m, when I change self.userInteractionEnabled = NO; to self.userInteractionEnabled = YES; I'm getting the touchesBegan event in the AFItemView.m that it already implement UIView, but flow doesn't work when I apply to this change.
I'm wondering where is the my mistake ?
Any help and example code would be appreciated.
Edit :
Let me explain my goal;
The target is user will open OpenFlow the scroll images with touch then when the touched any image that inside of the OpenFlow view, selected image will be come with zoom-in or flip or sth. animation. When the user touch to close icon which will be right side of the opened image, screen will be get back to the OpenFlow main screen, I did not find any solution to it on OpenFlow project. It's really urgent.
Regards
I've written this answer before: How to flick through a deck of cards?
The summary:
Once hitTest:withEvent: returns a non-nil value, it's over (by default); that view "owns" the touch (see UITouch.view). Only that view gets touchesBegan/Moved/Ended/Cancelled:withEvent: callbacks.
The touches are being grabbed by AFItemView, so AFOpenFlowView never gets touch events. It may be easier to add the necessary touch-handling to AFOpenFlowView instead.
Alternatively, you can implement touch-forwarding in AFOpenFlowView. It's a bit tricky to get right.

Using lock screen for my app?

I'd like to make my app use the audio buttons on the lock screen while multitasking.
(Yes, like Pandora.)
What API am I looking to use?
See the Remote Control of Multimedia docs. Basically, you just need to call -beginReceivingRemoteControlEvents on your shared application instance, then register something (probably your main view controller) as the first responder and implement the -remoteControlReceivedWithEvent: method on it. You will get events both from the lock-screen controls and from the headset clicker, as well as the control buttons to the left of the multitasking drawer. To play audio while your application isn't foremost, you should also check out this information on background audio.
It is even easier now, as of iOS 7. Here's the example for the play/pause toggle (headset button). See the docs for MPRemoteCommandCenter and MPRemoteCommand for more options.
MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter];
[commandCenter.togglePlayPauseCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent * _Nonnull event) {
NSLog(#"toggle button pressed");
return MPRemoteCommandHandlerStatusSuccess;
}];
or, if you prefer to use a method instead of a block:
[commandCenter.togglePlayPauseCommand addTarget:self action:#selector(toggleButtonAction)];
To stop:
[commandCenter.togglePlayPauseCommand removeTarget:self];
or:
[commandCenter.togglePlayPauseCommand removeTarget:self action:#selector(toggleButtonAction)];
You'll need to add this to the includes area of your file:
#import MediaPlayer;

Touches on UILabel

In my program labels didnt detect touches while i testig on simulator. but it works fine on device. why does this happens?. i want to capture the video of my application when working on simulator.
If you need a quick workaround for recording video, just put a clear UIButton over top of the label that calls the same function upon tap.