Track Finger Touch on UIButton and execute it's action [closed] - iphone

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have a view with several UIButton instances. Now I'd like that the user can trigger als button when he wishes over it with a long touch. So he can either touch one button or wishe over several buttons. Therefore all button actions of the touched buttons should be executed.
Here's a photo (buttons with red background color and black border):
Thanks for your help!
Best regards from Bavaria,
Chris

If I understand the question right, what you need with your grid of buttons is UIPanGestureRecognizer.
You can add the same recognizer to every instance of UIButton and handle all its states (UIGestureRecognizerStateBegan, UIGestureRecognizerStateChanged, UIGestureRecognizerStateEnded).
If you want certain delay in detection (like UILongPressGestureRecognizer), you can trigger timer and check if finger is still inside the UIButton's frame.

Related

How can i Stop UITableview cell reloaded While Scrolling the UITableview in iPhone..? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I have already tried to implement UISwitch in the tabeleview cell,now the switch state is automatically changed while i scroll and change the view ,
Please guide me....
You can use NSMutableDictionary for holding the information regarding particular cell UISwitch object. If you have enable a UISwitch button for a cell then set Bool yes and tag value as well in the NSMutableDictionary.
Enable the switch for a particular cell object according to NSMutableDictionary values in cellFor rowAtIndexPath.
UITableview reuses the cells, to solve your problem you need to create NSArray for switch states and assign as user scroll up and down (Using NSIndexPath).

Custom UISwitch with image [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to implement a custom switch in a project. Currently what I have found is that we cannot alter with UISwitch in way to implement as shown in below image. I've followed posts and googled through stackoverflow and other blogs but didn't found a solution as desired. One way is to go with UISegmented control as in this post, but that too doesn't solves my problem.
Thanks in advance for any help
It's not hard to create your own switch. A UISwitch is a control — essentially just a view that sends a message — with two states. You could set it up your own custom control like this:
container view: a simple view with rounded corners (set the cornerRadius of the view's layer) and a background color
left image: an image view that displays the image you want to show on the left side, i.e. the check mark for your example
right image: an image view that displays the image you want to show on the right side, i.e. the X mark for your example
slider: an image view showing the slider portion of the switch, set above the other two image views
When the user taps or swipes the control, use Core Animation to move the slider to the other side of the switch and update the state of the control and do a quick fade to the background color for the new state. Send the control's action to the target.
As gasparuff says, you can also do it with a UIButton, just set the images:
[button setImage:[UIImage imageNamed:#"image_on"] forState:UIControlStateSelected];
[button setImage:[UIImage imageNamed:#"image_off"] forState:UIControlStateNormal];
and when it's tapped just toggle the selected property.
- (void) buttonTap {
button.selected = !button.selected;
}
Which will change the images automatically.
You know about -[UISwitch setOnImage:] and -[UISwitch setOffImage:], right? Also -[UISwitch setTintColor]. About the only drawback I can see is that the switch, itself, will be the standard iOS switch (round button) but, otherwise, this would be the most-iOS-like solution.
When implementing your own on/offImage, remember the size restrictions, and also that the side of the image toward the switch is concave. tintColor can be used to make the rest of the switch reflect your color scheme. You might want to track the valueChanged event so alter the tint color.
If you need the exact look you display in your question (square switch button), then you probably want to use a custom control, as #Caleb suggested.
It looks like you just want your control to have only 2 states - enabled and disabled.
An easy way for this would be to create 2 png-images and use a custom UIButton with a background image and just replace those 2 images each time the button is tapped.
Is this what you are trying to do or did I misunderstand something?

Orientation with multiple view controllers [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Is it possible to have the following?
When I rotate my iOS Device, the ViewController switches, as in I have RandomViewControllerPortrait and RandomViewControllerLandscape. I have the feeling that if I support both orientations, that the ViewController class gets quite "bloated".
Is this idea useful at all?
I think having 2 view controllers for different rotations would be a bit redundant. I think what you want to use is 2 different UIViews for different orientations, and your UIViewController handling the methods for rotations being called. When your application rotates, you can set self.view to be either portraitView or landscapeView. You can even animate the view change with an animation block, so the transition looks smoother.

play rewind and stop button on UINavigationController [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
Requirement of my app is to have UINavigationController at the bottom with play, rewind and stop buttons on it. Play button will play audio and will have multiple ViewControllers. what should be the code to display UINavigationController at the bottom
UINavigationController should generally go at the top of the view (as per the H.I.G.).
A bar at the bottom should be a UIToolbar where you create your own buttons (UIBarButtonItem) and give them to the toolbar.
UIBarButtonItem has default items for Play, Stop, and Rewind (and many others)
If you already use a navigation controller, you can show its default toolbar (setToolbarHidden:NO) and create/set the items in the same way.
UINavigationController is a container that maintains a stack of UIViewControllers and a NavigationBar. You could try using the UINavigationBar separate, but you'd likely be better off just making some custom graphics on an imageView at the bottom.
Got it with the frame definition display it at the bottom like
MyCustomNavigationBar *navigationBar = [[MyCustomNavigationBar alloc] initWithFrame:CGRectMake(0, 435, 320, 25)];

i want to fix my table view while i am scrolling [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
while i am scrolling my table view gets moving upwards ..
i hav created table view programmatically without using IB so i should able to fix the position of table view while scrolling also...
how to do this..
any suggestions appreciated..
Do you mean you dont want the table to scroll at all? If so then this should do it.
tableView.scrollEnabled = NO;
Are you embedding a UITableView in a UIScrollView? It sounds like it. Don't. UITableView is already a subclass of UIScrollView and supports scrolling on its own.