iphone - Ways to switch views by swipe -


i'm building iphone app display news articles.

for reading 1 article, have view uitableview in it, display contents of article.

what need : want user able swipe next article finger, , effect pagecontrol sample of apple, or swiping between picture.(moving , forth visual effect)

questions : way it, uiscrollview , "pages", or there simple way include detecting swipe + manipulate switch effect + pushing view controller ?

other direction thought if can create 1 view 1 horizontal tableview, each cell show 1 article, , user swipe move next cell.

btw- fox news app iphone has feature, seems use "page control" solution.

any info help.

page control not solution think. imagine got views in viewcontroller , when detect swipe , direction, have :

  1. add content view appear
  2. add view subview of view controller
  3. place view on correct side (on left if user swipes right)
  4. finally animate views moves (position) correct direction

and you're done...

here example :

// in uiviewcontroller subclass uiview *viewone, *viewtwo;  -(void)swipefromview:(uiview *)visibleview               toview:(uiview *)pushingview            direction:(uiswipegesturerecognizerdirection)adirection {     // assuming content of pushingview set     cgpoint visibleviewcenter = [visibleview center]; // register center     cgrect visibleviewframe = [visibleview frame];     cgpoint pushingviewcenter, visibleviewnewcenter;      visibleviewnewcenter.y = visibleviewcenter.y;     pushingviewcenter.y = visibleviewcenter.y;      // use 2 here, make more calculations     pushingviewcenter.x = 2 * visibleviewframe.width;     visibleviewnewcenter.x = -1 * 2 * visibleviewframe.width;     // reversing x if direction right     if(adirection == uiswipegesturerecognizerdirectionright) {         pushingviewcenter.x *= -1;         visibleviewnewcenter.x *= -1;     }     // once tmp center pushingview calculated     // set it, , run animation     [pushingview setcenter:pushingviewcenter];     [uiview animatewithduration:thedurationyouwant                      animations:^{         [visibleview setcenter:visibleviewnewcenter];         [pushingview setcenter:visibleviewcenter];     }]; }  // somewhere else, handle swipe -(void)handleswipegesture:(uiswipegesturerecognizer *)sender {     // set content, etc     [self swipefromview:viewone toview:viewtwo direction:[sender direction]]; } 

hope helps.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -