How to speed up scrolling in UIScrollView? [closed] - ios

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I want to make paging/scrolling in UIScrollView to be faster, so when the user lefts his finger the next page will come faster than normal regardless the speed of the acceleration.

Tweak the decelerationRate of your UIScrollView.
More reading: UIScrollView Class Reference

If I understand your question correctly, you've setup the ScrollView to snap to pages (pagingEnabled = YES). When the the user lifts their finger you want it to snap to the closest page quicker than what it currently does?
If that's what you're trying to accomplish, this is what I recommend:
DISABLE pagingEnabled (pagingEnabled = NO). We're going to do it ourselves.
Setup some object (probably the ViewController) as a delegate of the scroll view.
In the Scrollview delegate, override the method scrollViewDidEndDragging:willDecelerate:. You will also want to override the method scrollViewWillEndDragging:withVelocity:targetContentOffset: so that you can get the velocity of the drag.
In the scrollViewDidEndDragging:willDecelerate:, you can calculate the direction of the drag (using the velocity you got from the other method) and the offset to the nearest page. From there, it's as simple as setting the contentOffset of the scrollview using a UIView animation block with the desired duration. For example:
[UIView animateWithDuration:.25f animations:^{
scrollview.contentOffset = calculatedCGPoint;
}];
That should give you the desired effect.

Related

Changing UIImage using an IBAction [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
Good morning,
I am trying to create a button, that, when pressed, will change the background to a different image.
For example; we have;
background1.png
background2.png
background3.png
background4.png
background5.png
background6.png
background7.png
background8.png
background9.png
I want the app to start, and use background1.png as the default.
However, I would like to set a UIButton, to change the background when pressed, that will just cycle through the backgrounds from 2-9.
Is that possible to do at all? At present the Background image is set in the IB using 'background1.png' so I am guessing I would need to remove that, and set it to appear in the viewdidLoad?
Sure, set the image view containing the background image to an IBOutlet.
Then, in the IBAction pointed to by your UIButton, each time that action is called you can cycle through the various image files and set the image contained in the UIImageView.
e.g.:
- (IBAction) changeBackgroundImageAction: (id) sender
{
// someIndex can be an ivar or something else...
NSString * imageFileName = [NSString stringWithFormat: #"background%d.png", someIndex];
backgroundImageView.image = [UIImage imageNamed: imageFileName];
}

Set background color for UIView [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I have a problem when setting the background color for a UIView. What I am doing is:
- (void) viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor clearColor];
}
but I am getting a black background color as shown below:
If I change the background to any another color it works. Any ideas about this ?
Your view is working as intended. You are setting it to use a clear background color, which means exactly as it is named, clear, and you will see color and possibly other UI elements underneath your view. Think of it as placing clear plastic wrap (the view) on top of colored construction paper (the super view). If you wish to find where the black color is coming from, I would start with your root controller's view.

iOS: How do I create a sliding view/text bubble that slides in based on your finger gesture? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I need to create a new view for an app where the user is presented with a screen with a status bar, a text bubble and several buttons. They will be allowed to slide the text bubble off the screen and a new one will slide in to take its place. I only want the user to be able to move one bubble at a time. Where can I find a guide for coding something like this?
1) I have not done anything touch based, but I've heard of using UI Gesture Recognizers.
2) I need to know how to slide in the text bubble (which will have dynamically generated text) but not slide out the entire view. There are going to be buttons and status bars on the main window, so those have to stay, while the user is sliding through the text bubbles
You can use UISwipeGestureRecognizer to detect when the user flickes his finger over the screen:
UISwipeGestureRecognizer *rec = [[UISwipeGestureRecognizer initWithTarget:self action:#selector(swipeDetected:)];
[someView addGestureRecognizer:rec];
[rec release];
Then you can use UIView animations to slide in any view:
[UIView animateWithDuration:0.5 animations:^{
CGPoint ctr = textBubble.center;
ctr.x += 100;
textBubble.center = ctr;
}];
See UIGestureRecognizer and UIView class reference for further info. You also might find this link useful.

How to know which key is pressed on UIKeyboard in ios? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am implementing a iPad application. In my application I need to know which key is pressed in the keyborad. Can you guys please help me is there any way to find it?
Thank you,
Sekhar.
This is a vague question, but if you simply want to know what key has been tapped you need to implement a delegate for input control that called the keyboard. For example if you are using a UITextView, then implement the UITextViewDelegate, wire up the control's delegate property to you class, and then implement the textView:shouldChangeTextInRange:replacementText:. When UITextView recognizes a change then it will call this method. You can then watch for the characters in the "replacementText" argument.
With UITextField use the UITextFieldDelegate and implement the textField:shouldChangeCharactersInRange:replacementString: method.
You can do other things with UITextField like change the Return button to a Done button in Interface Builder. The implement the textFieldShouldReturn: method. If it's called then run the resignFirstResponder on the object passed to the method.
Hope this helps.

How to hide UITextField, UILabel, UIButton on ViewDidLoad method? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I am trying to hide my texts labels and buttons
Use the hidden property of UIView (UITextField, UILabel and UIButton are all subclasses of UIView).
myControl.hidden = YES;
go to the .h File for the view controller and make an IBOutlet with the data type appropriate for your control UITextView, UILabel, etc...
go to the interface builder and bind the IBOutlet you declared to the item you want.
Use myControl.hidden = YES;
Please do not hesitate to ask for clarifications for any of these steps.

Resources