How to add a slider to move downward in view? [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 9 years ago.
I am new to iOS programming, so I hope its not a stupid question to ask. I have to add ten different buttons in my view programmatically. I know how to add buttons programmatically, but my buttons won't fit within the view so some of them have to be present below the viewable height of the view, so I want to add the buttons such that the user can slide upward and downward to move across the view. How can this be done?

There are a number of standard UI elements UIKit provides that help handle displaying more content than the screen can display at any one time:
UICollectionView
UIScrollView
UITableView
You may benefit from some of the automatic layout and formatting provided by the UICollectionView but from your description it sounds as though either the UIScrollView or UITableView would be best suited for your scenario.
UIScrollView
The UIScrollView acts as the user's viewport into the underlying view it contains and provides complex panning and zooming functionality by default. It is highly configurable and you can prevent zooming functionality if you do not need it.
Just make sure to place your view inside the UIScrollView within Interface Builder and set the contentSize property. Setting a contentSize larger than the bounds of UIScrollView should enable scrolling automatically. To enable zooming have your UIViewController implement the UIScrollViewDelegate:
#interface MYViewController : UIViewController <UIScrollViewDelegate>
#end
Then ensure to return your view in the viewForZoomingInScrollView: method:
-(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return theViewContainingTheButtons;
}
UITableView
The UITableView is specifically designed to display a list of items that can be vertically scrolled if its content is taller than the size of the view.
A UITableView is composed of a number of UITableViewCells, each of which could contain one of the buttons you wish to display. Apple's Table View Programming Guide for iOS covers most aspects of the UITableView.
Conclusion
The UITableView approach focuses specifically on what you have asked and neglects that there may be other content in the view hosting the buttons. It also means that you would have to change your existing dynamic button placement code and write new code to work with table views. In reality it's likely that the UIScrollView is what your looking for but I wanted to provide exposure to other UI elements you may not have been aware of that could be used to achieve what you have described.
Good luck!

You need t use a special element, called a UIScrollView. It will handle all this automatically. Here's a link to the docs:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html

You can use the UIScrollView.
Instead of adding UIButton to UIView addd then to UIScrollView and set UIScrollView contentSize.
Fore more help : UIScrollView from Apple.

Related

How to pin an image/view inside a UIScrollView when scrolling

I've been searching for a way to pin views/images to the top of a UIScrollView when scrolling. However the posts/articles I came across are not in swift 3. I'm not sure if I'm typing my question in the web correctly. So my question is how can we achieve the same behavior as a UITableView or UICollectionView. When you scroll, a section will stick to the top until another section pushes it up. I'm wondering would we be able to use views/image and pin them at the top of the UIScrollView. Down below is a screenshot of a UIScrollView that has 4 views.
So when scrolling I would like to pin the first view/image to the top until another view/image pushes it. Also would it be possible to determine which view sticks to the top. So lets say I only want the red views to stick until another red view pushes it. Been looking for a way to achieve this type of behavior for a while now.
Please help, would really appreciate any help provided at this point. Thanks.
A few ways to do this, but you can use the scrollView delegate’s scrollViewDidScroll to capture the contentOffset and use a combination of the target view’s origin/center/transform properties to keep the view where you want it.
There’s a neat video explaining how to do this that Apple released during WWDC 2010, called something like “Advanced Scroll View Behavior”, if I remember correctly. It’s definitely worth a watch.

IOS UITableViewCell - Swiping Sections

I have a brief that requires a swiping panel view to display a staged fitness plan event - basically I need something that swipes uitableview sections horizontally similar to the way the suggested Apps panel works - i'd need to use custom cells - no idea if this is possible as I cant find any information anywhere to guide me - does anyone have any experience or can offer any advice!?
At the simplest level you can just stick a UIScrollView in the cell. If you need to put a lot of elements in there and performance is a concern you would use a UICollectionView with a layout like the built in UICollectionViewFlowLayout with horizontal scrolling. Then, each of those elements would just be a UICollectionViewCell.

How to scroll cells only and not the entire tableview? [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.
How do you disable tableview scrolling but enable cells to scroll within the section similar to how path for iPad does their friend and and notification cells, they are collapsable but the cells under the section only scroll within the section as in the section does not move to the top of the device but remains in its position.
There is no such controls available in iOS.
Possibly it is a customized UITableView. According to your description, each section of that table will contain another UITableView not simple UITableViewCell. That's why it have the feature you specified.
I had seen some open-source controls with similar feature, but forgot the name of those controls.
Your question is too broad, its better if you can add more details. But I will give you a rough answer to my understanding of your problem. What you can do is use UITextView in side your tableview cell and depending on the scenarion you can disable the scroll. It is recommended you keep only one scroll view scrollable at one time. UITableView is also inherits from UIScrollView. You can set the scroll disabling to your gesture handle methods or in a expanded cell scenario. To set scroll disable you can set scrollEnabled property to no.
Refer to http://developer.apple.com/library/ios/#documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html#//apple_ref/occ/cl/UIScrollView

UICollectionView - Horizontal paging with 3 pages visible and 1 in the middle using UICollectionView [duplicate]

This question already has answers here:
UICollectionView: paging like Safari tabs or App Store search
(6 answers)
Closed 9 years ago.
I'm trying to implement same feature like mobile Safari has when scrolling among different pages using UICollectionView. One page is in the middle and parts of other are also visible.
I am struggling to achieve such a behaviour using UICollectionView. There is 1 way I found how to put 3 pages at one screen - make pages smaller and set appropriate insets. But as soon as I set pages smaller and I set paging enabled, pages are not scrolled to the centre as they should. I can also leave paging disabled and use this method in subclass of UICollectionViewFlowLayout:
- (CGRect)rectForTargetPageForProposedContentOffset:(CGPoint)proposedContentOffset withScrollingVelocity:(CGPoint)velocity
In this method I can set exactly where UICollectionView will stop. However, scrolling experience is not as good as it was as using UIScrollview with paging enabled. When I swiped with bigger velocity, several pages were scrolled and it stopped on proposed page. What I want to achieve is same behaviour as normal scroll view with paging enabled - whatever velocity I use, I will get only 1 page more.
Do anyone have any idea how to solve this using UICollectionView?
So you want to make size of a page smaller than the size scroll view, right? Page size is always the same as the size of scroll view, so you have to make the scroll view smaller.
Then there is another problem. How to receive touches out of the bounds of the scroll view?
Override -[UIView pointInside:withEvent:] of the scroll view to check for larger bounds than they really are. Then the touches should work.
In fact I didn't try this myself, I was doing it by placing supplementary view above with desired bounds and override -[UIView hitTest:withEvent:]. Inside I modified the point and called scroll view hit test. This way the touches were handled by scroll view, but their position was wrong. You may want to try combining these two approaches to get correct position.

How do I create a view in iOS 5 which can scroll in any direction, like a map?

How do I build a freely scrollable view on iOS 5? I mean, I need to build a view which can scroll from left-right and top-down (any direction) and it will stay there. Inside this view, I need to place different kinds of objects.
(Imagine scrolling like a map. - I am using Storyboard.)
Yeah, UIScrollView.
And don't forget to set the content size !! (every noobs - including me - are always asking the same question, why my scrollView does not work?)
=> [scrollView setContentSize:CGSizeMake(1000, 2000)], for example.
EDIT :
I just saw your comment. I don't understand what you call "on top".
I made an app with custom maps, and I used an UIScrollView to make the job: it was pretty good at it.
You just have to add each scrollable element as subviews of your UIScrollView. And set the contentSize to fit to the subviews' frames, of course.

Resources