ScrollView not working in iPad simulator? - objective-c

First off, how do you test scrolling in the iPad simulator? I have a touch pad and I've tried dragging two fingers and I've tried click & dragging two fingers, but I can't get it to scroll. Am I doing that part correctly?
Assuming that I'm testing properly, why won't my scrollview scroll? I have a basic view controller in my storyboard and I dragged a scrollview into it. I made an outlet from it into my code and then in my code I generate a bunch of buttons and add them to this scrollview. They get displayed properly. Am I missing something?

set scrollview content size such
[MyScrollView setContentSize:CGSizeMake(320, 500)];
this is for iPhone for example.
You can also make two fingers by press the alt key next to cmd in mac
HOLD PRESS alt + mouse move on simulator

set contentsize of the scrollview,to enable scroll.
Detailed explanation
https://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/UIScrollView_pg/CreatingBasicScrollViews/CreatingBasicScrollViews.html

You have to define the contentSize of scrollView which is generally bigger in frame than parentview or its frame to make it scrollable.
[viw setContentSize:CGRectMake(width,height)];
set it in viewDidLoad or where You alloc srollview.

Related

UITableView Inside UIScrollView scrolling issue

In my application I want add a tableview inside a UIScrollView .When the scroll of UITableView reaches the bounce, it should scroll the outer scrollview. But its not happening for me, UITableView is scrolling smoothly.Once it reaches the bounds, it stops. I need the functionality similar to the attached gif .
Please provide some code & you UIScrollView must be smaller than the view.

Detect how far the keyboard has animated?

I would like it to appear the keyboard is pushing another view up. The problem is there is a UITabbar between the UIView I would like to animate in unison with the keyboard, problem being the UITabbar breaks up what would give that appearance. What I would really like to be able to do is detect when the keyboard is at the exact point my view then animate that view.
Is this possible without going into the private API's?
Too be clear I have the animation working, just working out a way to make it smoother. The effect I am trying to create is similar to the messages app, but there is a UITabbar between to UIView and the bottom of the screen.
Perhaps this will work...
The height of the keyboard on the iPhone is 216 pixels. The default animation duration for the keyboard display is 0.25 seconds.
The height for a tab bar is 44 pixels.
So, if you started the UIView transition animation afterDelay:((44.0/216.0) * 0.25), this should look right on an iPhone. Perhaps try and see?
If this works, it's pretty easy how to figure out for landscape, and iPad, etc.
Additionally, if this does work, in your final implementation, I would avoid hardcoding the 0.25.

xcode adding button to uitabbarcontroller is not clickable on landscape

I am adding a simple button into a view on a tabbarcontroller to the bottom right of the view. This button is clickable only when it is on portrait, not when the app is flipped to landscape. The app is using autolayout, so I've added two constraints so it hugs the bottom right of the view on landscape and portrait. Horizontal space at 20 and Vertical space at 24. I've tried this on a UIViewController without the UITabBarController, and it works perfectly. But once the view is added to a tab, it stops working. How do I get this button clickable on both portrait and landscape?
This seems like a very simple setup, but I have no idea why this does not work.
![snapshot2]http://ownits-stackoverflow.s3.amazonaws.com/snapshot2.png
![snapshot3]http://ownits-stackoverflow.s3.amazonaws.com/snapshot3.png
I tried the same thing it works. Here is the sample code try to run it on your own simulator and on device.
Sample Project

UITableView Scroll when touch starts on subview

i have a tableview with different kind of cells, one of which has some UITextFields's and UIButton. When i try to scroll this view with the touch starting in any of those subviews the table won't scroll and recognizes it as a 'touch inside' of a subview. I had it before with "delays content touches' but the touch inside button doesn't work well. Any ideas how i might fix this problem?
I just found i had an 'UITapGestureRecognizer' that was creating the problem. thank you for the help
Turning off "Cancellable Content Touches" in the UITableView solved this for me (in the UITableView attributes inspector under Scroll View / Touch). I got this from this SO question: Scrolling a UITableView inside a UIScrollView
From the UIScrollView:canCancelContentTouches doc:
If the value of this property is NO, the scroll view does not scroll regardless of finger movement once the content view starts tracking.

Xcode scroll on buttons

I have a scrollview in my app, in the scrollview there is a lot of buttons without any space between them... When I run the app, I can't scroll because I "of course" have to touch a button first, and ehen I try to scroll, the button that I touched gets highlighted, and when I release.. The button is pressed! So I can't reach the buttons that is further down in the scrollview!
All button has the setting "Touch up inside"..
I guess it is kinda easy to fix, but I don't know how! :P
/Noob
Setting the property canCancelContentTouches on the UIScrollView to YES should allow it to cancel the touch event already sent to the button once it detects a scroll. That should fix your problem.
You can do what ksoderstrom said or you can auto scroll using this method for your scrolview
[self.scrollView scrollRectToVisible:textField.frame animated:YES];
textField can be a UIButton as well. This method will just move the scrollView to whatever component you specify.
Hoep it helps.
I had the same problem and i found out that it's really hard to test it in the simulator. When the code run on the actual device, the scroll view was working as it was supposed to...