moflo / openspringboard

UIKit based Spingboard clone, similar to Three20's TTLauncherView. (Update Aug-9-2011: finally have time to refactor this for iOS5 custom container view controllers)
http://fieldforceapp.com
MIT License
242 stars 38 forks source link

Add UIScrollView support #4

Open iamcam opened 13 years ago

iamcam commented 13 years ago

It would be great to have support for either a continuous vertical scroll or paged left/right as Springboard does it

moflo commented 13 years ago

Makes sense. Animating the icons on-to and off-of these UIScrollViews could be complicated.

iamcam commented 13 years ago

Perhaps focus on a vertical scroll version first. If anything a user can reposition the view vertically and keep moving until satisfied with the position.

iamcam commented 13 years ago

I know 320 does it, but I confess I don't fully understand that level of programming. I don't think they're using UITableView-like classes and methods, either, so that might be part of it.

moflo commented 13 years ago

They subclass UIScrollView, but we wont need to: this openspringboard code works on UIView containers and it doesn't matter whether that container is static or stuffed within a UIScrollView. The delegate methods should eventually take as input your UIView, and then insert either the icon/text/badge containers or a UIScrollView with those containers as subviews. The easiest way to do this would be for us to have a parameter to specify the maximum number of icons per UIView, and deduce UIScrollView "panel" counts from that.

johndpope commented 12 years ago

just add some tags so you can handle the data call backs

if (openSringBoardVC.tag ==1) do page 1 icons.

etc

boom

    pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(160-40,480-44-20-40, 80.0, 20.0)];
    [pageControl addTarget:self action:@selector(:) forControlEvents:UIControlEventTouchUpInside];
    pageControl.numberOfPages = 2; // must be set or control won't draw
    // in case the parent view draws with a custom color or gradient, use a transparent color
    pageControl.backgroundColor = [UIColor clearColor];

-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{

pageControl.currentPage = [self determineIndexFromCurrentScroll];   

}

-(NSUInteger)determineIndexFromCurrentScroll{ ENTER_METHOD; float w = mySV.contentSize.width/ numberOfPages; CGPoint pt = [mySV contentOffset]; CGFloat x = pt.x / w;
return (int) x; }

moflo commented 12 years ago

Thanks, John. I like your approach. We've been debating whether to support landscape mode & then how to handle moving icons between different pages. Any recommendations?

johndpope commented 12 years ago

let's hold back on the landscape mode.

in the apple sample code for "Autoscroll" from wwdc / scroll view suite, there's some code and in movie the guys steps through logic for handling long holds and responding to this gesture when icon hits side of the screen.

This multi page containers is going to be a royal head ache to cross this logic over into different views. They are each going to need to talk to each other - and is going to have a lot of wiring necessary for each page.

it's probably better not to go down this path that I've started. For me - it gets the job done for now. It would so much easier if they were all in one view which spands multiple pages within the one uiscrollview.

if icons being added go beyond (iconsPerPage) > then offset the new ones by device screen width * pageNumber and reset the y position.

then you wont need to change the existing moving logic - just handle events when we hit the sides of the screen.