Manipulating scroll view in Corona SDK - lua

I have a class with a scroll view that has a width of 980. I also have about 100 buttons aligned 5 columns x 5 rows for each 320 width of my scroll view. The scroll works okay but I'm trying to achieve two things:
Allow scrolling only when slide length is about 50% of screen size
If the slide length is half the screen size, then it would immediately slide/scroll to the next 25 items. For example, in plain sight you would see buttons 1-25 then if you try to scroll, the next 25 objects would be displayed (buttons 26-50).
I followed the sample from here but I don't know how to implement what I want to do or if it's even possible to do this using scroll view. I hope someone can give me a good example or idea. Thanks.

Try something like this: http://developer.coronalabs.com/code/slider-module-springboard-functionality-warning-shameless-promotion-inside. It works sort of like the iOS springboard.

Related

UICollectionView Full Screen Vertically and 2 Screens Horizontally

I have a UICollectionView that displays one cell at a time that has the size equals to the UIViewController.view.bounds.size. This works great for me on Vertical/Portrait screen.
I want to rotate the screen to landscape and a nice animation happens to show 2 cells side by side each having size equals to CGSize(UIViewController.view.bounds.width / 2, UIViewController.view.bounds.height)
Is there a library that does that or how can I achieve this approach?
You can think of it as an image gallery that displays one image at a time when rotated should show 2 images.
If you are using flow layout, then all you have to do is implement UICollectionViewFlowLayout delegate methods, and invalidate the collectionView's layout on rotation.
Take a look at this repo: dynamic width cells
It's not exactly what you are looking for, but you can get a general idea.

UIPageViewController with 4 direction scrolling

I have created a grid view with the some images on UIView, which should like default iOS Photos app Collection [Screenshot attached]
When clicking on an image, it should show the full image in a screen with UIPageViewController
i added the FullImages with UIPageViewController but it is only two directional, i can only scroll from left to right and right to left OR top to bottom and bottom to top, But i want to do both at a time
for example:
I have 9 images in the following order
1 2 3
4 5 6
7 8 9
suppose i'm at image 5
if i scroll from top to bottom i have to go to image 2
now, if i scroll from bottom to top i have to go to image 5
now if i scroll again from bottom to top i have to go to image 8
now if i scroll from right to left i have to go to image 9
now if i scroll from top to bottom i have to go to image 6
now if i scroll from left to right i have to go to image 5
can somebody suggest how to achieve this?
can i use the UIPageViewController or any other control to get this effect
I would use UICollectionView for Grid layout for photos.
You can't set both dimension scrollability of collection view. But you will achieve this by using Multiple Section
As an example :
I think you need something like this.. Just remove First Row & Columns. & add ImageView instead of Just Text..
http://www.brightec.co.uk/ideas/uicollectionview-using-horizontal-and-vertical-scrolling-sticky-rows-and-columns
Another good eg is: https://github.com/izotx/ScrollableCollectionView
& if you want to load view at the middle photo of grid then set ContentOffset of that collectionview accordingly..
As far as i understand your problem, this solution should work in your problem..
Try this out & inform me if you solve it or not. Or you get another best solution..
A UIPageViewController will not do what you want. Think of it like a book. That's what it offers. It won't offer scrolling through a grid of pages like that.
A customized UICollectionView is probably the best starting point for what you want.

ios 8 layout using uitableview static cell & uitableview dynamic prototypes

I work on a app, nothing fancy, but since is my first app, there alot of stuff I never did before.
So, I'm trying to build a view like the image attached.
I've looked up on the Internet how to do something like that but I don't know what is better/cleaner way to do.
As you can see I have 3 areas: the title, the tableview in the middle and a button on the lower side.
The table will expand based on the content (3 lines or 30 lines) so the button must move down and a scroll bar should appear.
So, my idea:
Using a tableview having 3 static cells: one to put my title, second to put a tableview having prototypes cells, and a third one for the button.
That way I would have a scroll bar when the table in the middle grows, pushing the button.
Here I have a question: how to have the table view (the inner tableview) resize itself, pushing the height of the middle row, instead of having a fixed width with a scroll.
Is the the best way to achieve that?
Thanks for any idea.
C.C.
Are you sure you want to push the bottom UI down as the table grows? You say whether the table has 3 or 30 cells, but what if it has 300 cells? Your user then has to scroll to the bottom to reach the button and tab bar. I think you'll find that it would be better to use Auto Layout and let the table fill the screen space between the title and the button. The table will scroll so if you have 300 cells then you can scroll through inside the table's available area.
The advantage here is you won't be fighting with Auto Layout. If your user rotates an iPhone 4S into landscape you'll only have a few rows displayed but conversely if they run in portrait on an iPad you'll fill all of that space.
As for how to do it, the other advantage is that you don't need the nested table you describe. Use a constraint to attach the title label to the top layout guide, then attach the tab bar to the bottom layout guide. Put a vertical space constraint between the button and the tab bar. Finally, put vertical space constraints between the table and the title & the table and the button. (You'll need to implement constraints for the horizontal axis as well, but that's pretty simple.)
There's are refinements you can put into place if you want the table to shrink to fit if there are only 3 rows, but this should get you started and you may not want that anyway.
Key point: the tableView wants to scroll naturally, inside a view sized to fit the display. Don't change that behavior unless you really have to. Neither your users nor UIKit expects what you're trying to do, and the table is going to fight you all the way about it.
Nesting UIScrollViews (which your nested table would do) works, but it opens up a lot of bad UI flow problems. In my experience every time somebody wants nested scrollViews there's some other approach which is more "natural" to iOS interface paradigms.
If you're dead set on the UI you described I wouldn't use a table for the outer structure. Just make it a UIScrollView and calculate your content size based on the number of rows the table will display. You can actually do that, and then use Auto Layout as I described.

xcode, align 20 images, grid view

Need some help ^_^,
I'm trying to align 20 images together, in the storyboard,
https://www.dropbox.com/s/cnyojn82rn84c9j/pic1.jpg?dl=0
https://www.dropbox.com/s/05u50dd54w756q7/pic2.jpg?dl=0
I need them to look same in the portrait and landscape mode, so if you imagine rotating phone, then 20 pictures rotate 90 degrees, but not the whole view, when view rotates to landscape, bottom row disappears.
Sorry, it's hard to explain =D, basically in portrait top row has 4 pictures, in landscape top row should have 5 pictures.
Would be even better if they would change size of the image depending on the screen size.
Thanks,
Why there is need of 20 images to be designed in storyboard, When we have UICollectionView for that purpose, you never need to worry about the rotation, Collection view will automatically adjust it cells accordingly.
If you need tutorial you can surely go ahead with this link
I suggest you look into UICollection views with a flow layout. It might sound unwieldy at first but it is definitely the best solution for what you want to achieve. Apple documentation can be found here: https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/CollectionViewPGforIOS/CollectionViewPGforIOS.pdf

iOS UIScrollView with multiple pages visible

I'm having a little issue with scrollview pagination.
My intention is to have 3 pages visible on screen and when I scroll right only on page is scrolled, following the example below, scrolling right will display page 2, 3 and 4 on screen:
However I don't know how to display mutiple pages at the same time, at the moment I have it like this:
Obviously like this is not what I want.
To achieve the desired functionality I tried making the scrollview's frame the size of the page I want (1/3 of the screen width) and setting the clipToBound to NO so the other pages are visible. This indeed shows 3 pages in the screen; however since the scrollview frame is only 1/3 of the screen I can only swipe in that area, I would like the swipe area to be the whole screen width.
You're on the right path. Now you can try manipulating UIPanGestureRecognizer of your scrollView, say, re-attaching it to scrollView's superview.
Alternatively, take a look at iCarousel, it can be perfectly customized to suit your needs.
My solution in the end was the following:
I took my initial approach.
I disabled the scrollview's scrollEnabled property.
Added swipe gesture recognisers to the scrollview.
When the gesture is made I modify the scrollview's contentOffset to move 320/3 pixels to the right or left.

Resources