UIScrollView bounces on object press - objective-c

I have a UIScrollView with a bunch of buttons and switches present in it. When pressing any of these items the scroll view bounces to the top of the screen. While debugging this issue I increased the content size of the scroll view to be much larger than the space that I require and the issue does not happen. I should also mention that in in the hierarchy of objects within this view controller I do not have a UIView is it possible this could be causing my problem. I have tried adding a one in but it seems to break a lot of the UIScrollView features. Does anyone have any ideas as to why this is happening or what hierarchy structure should be employed when using a UIScrollView.
Thanks.

Related

Can't seem to achieve the same effect on my slide menu as Any.Do

I am trying to create the same type of slide-up/pull-up menu (from the bottom) as the Any.do iPhone app, but not having any success.
The issue I am running into is the app was built with storyboards so I am thinking I might have to scratch that idea and use just code.
Any ideas?
There is no need to get rid of your storyboard to recreate this, that's what IBOutlets are for. Any way, it looks like this was made by creating a UIScrollView that takes up the entire screen. Then add a UITableView to the upper section of the scroll view. Mind you in order for this to work, you'll need to disable scrolling on the scroll view in the background.
From there you can programmatically add the other elements to the scroll view to be rendered off screen, since there are only three they can probably just be buttons. And finally, since scrolling is disabled on the background scroll view you can add an image with a UISwipeGestureRecognizer at the bottom of the screen to manually change the scroll view's content offset property.

Why does my view get distorted?

My view consists of a toolbar at the top and bottom of the view and an imageView in between.
I am adding subviews to my image view.
When a subview is added, the whole view sometimes becomes distorted. The imageView will stretch, a toolbar and the bar button items shift as well.
What causes this? Has anyone came across this before?
Suggestions to fixing this matter?
Note: I have set up this view in Interface Builder, not programmatically.
Thank you!

How to know that User is still touching the screen in UIScrollView?

I have a scrollView. Typical tableView Cell. I did things a lot on viewDidScroll.
viewDidScroll is called on 2 cases.
User scroll
Sometimes user have stop scrolling but the scrollview still scroll anyway due to momentum, bouncing, etc.
So how do I know if users are still touching the scrollView?
UIScrollView has a BOOL property named tracking that is YES while the scroll view has a touch and NO otherwise. In my testing, it is set to NO as soon as the touch ends, even if the view is decelerating (and still sending scrollViewDidScroll: to its delegate). This seems like exactly what you are asking for.
In my testing, the dragging property doesn't seem to become NO reliably while the view is decelerating after the touch ends.
The decelerating property is also unreliable in my testing. If I touch the scroll view while it is decelerating, decelerating remains YES even though the view has stopped scrolling.
The delegate's scrollViewWillBeginDragging: is called when user starts dragging and scrollViewDidEndDragging:willDecelerate: & scrollViewWillEndDragging:withVelocity:targetContentOffset:(iOS 5+ without paging enabled) is called when user lefts his/her fingers.
You may also want to check scrollViewWillBeginDecelerating: and scrollViewDidEndDecelerating:.
Ref: http://developer.apple.com/library/ios/#documentation/uikit/reference/uiscrollviewdelegate_protocol/Reference/UIScrollViewDelegate.html

MFMailComposeViewController causes other controls to change position

I have three UIViewControllers being shown modally on top of each other. The third one opens a MFMailComposeViewController and send an email. However, after dismissing that view controller, various controls on other view controllers (not necessarily in the chain of view controllers) have moved in position.
For example, after dismissing the MFMailComposeViewController, one of the labels on the parent ViewController has moved down by about 20px. A scrollview on it's parent has also moved down the same amount. If I enter a separate view controller from here, an imageview is displaced. They always seem to be a control near the top of the screen, and only one per screen.
Has anyone seen this before? I've checked all the code and there nothing which could be causing it. I'm having to reset the frame on these controls every time the screen is shown to prevent them from appearing out of place. But it makes no sense to me.
Thanks.
Have you tried presenting it from the parent view controller?? I had a similar problem and it fixed the issue.
It sounds like layout randomly isn't happening, somehow. I can think of a few things to try:
Check that you're not expicitly calling -layoutIfNeeded, especially in places like -setFrame: or -sizeThatFits: — it can cause a layout of the entire view tree, which will tend to do the wrong thing if layout is already happenin (on iOS 5 it can cause inconsistent layout; on iOS 6 I've observed it getting stuck in a layout loop). You also need to be careful around some methods which perform a layout as a side-effect (UIButton.titleLabel comes to mind — the fix is to call it before adding the view to the hierarchy).
If you're using autoresizing then it should just work — except I've seen it not work if the view isn't attached to a window when its frame changes.
If you're doing layout in -layoutSubviews, override -setFrame: to call -setNeedsLayout. The usual symptom is that "switch tabs, rotate, switch back" results in an incorrect layout.

Laggy UIScrollView

At the moment I'm working on an iPad explore game which has a hexagon tile map.
I've created a UIScrollView that contains a background view (the game map) and buttons in the form of hexagons (for interaction). I add every UIButton to the view via addSubview.
But... when I add more than 100 buttons the view gets laggy (no surprise here). But what should I do to solve this?
Example:
scroll view http://img233.imageshack.us/img233/5527/screenshot2011090110353.png
Adding UIButtons isn't the way to go here. You should probably draw the "buttons" in a custom -drawRect: method and use -touchesEnded:withEvent: to decide what the user wanted to do.