Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6937025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:18:39+00:00 2026-05-27T12:18:39+00:00

I have developed a psuedo 3D carousel for the iPhone that looks pretty much

  • 0

I have developed a psuedo 3D carousel for the iPhone that looks pretty much like the image below:
enter image description here

I basically create an array of UIViews and then register for the touch events:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    // if we're not already tracking a touch then...
    if(!trackingTouch)
    {
        // ... track any of the new touches, we don't care which ...
        trackingTouch = [touches anyObject];
    }
}

While the movement is still being registered I do the following:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    // if our touch moved then...
    if([touches containsObject:trackingTouch])
    {
        // use the movement of the touch to decide
        // how much to rotate the carousel
        CGPoint locationNow = [trackingTouch locationInView:self];
        CGPoint locationThen = [trackingTouch previousLocationInView:self];

        lastAngle = currentAngle;
        currentAngle += (locationNow.x - locationThen.x) * 180.0f / self.bounds.size.width;

        // and update the view positions
        [self setCarouselAngle:currentAngle];
    }
}

I then call when the touches end:

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    // if our touch ended then...
    if([touches containsObject:trackingTouch])
    {
        // make sure we're no longer tracking it
        trackingTouch = nil;

        // and kick off the inertial animation
        animationTimer = [NSTimer scheduledTimerWithTimeInterval:0.03 target:self selector:@selector(animateAngle) userInfo:nil repeats:YES];
    }
}

The animageAngle method basically then calls another method with effectively divides 360 degrees by the number of views in the array and use the cosine and sine functions to generate the x and y coordinates.

The above all works good however, I am having difficulty comprehending the maths required to complete the following:

  1. Click on a view out of the main focus i.e. not at the front e.g the purple view in the image
  2. Rotate the purple view into focus i.e. to the front
  3. Load a new view controller once the rotation has complete

I understand that I have to calculate the angle between the view in its current position and the planned destination to make the rotation but I can not for the life of me figure it out.

Apologies for the prior confusion – I have been looking at this problem for sooooo long that I am starting to lose the plot.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:18:40+00:00Added an answer on May 27, 2026 at 12:18 pm

    Finally….I managed to crack it.

    I was acting incredibly stupid and was not thinking logically. I basically re-ran a NSTimer calling a method that run the following calculation on the currentAngle property (in psuedo code):

    CGFloat currentLocation;
    CGFloat nextLocation;
    CGFloat destinationLocation;
    
    currentLocation = viewImInterestedIn.frame.origin.x;
    nextLocation = currentLocation - 1; //or + 1 if the selected view is to the left of centre
    
    destinationLocation = 115.0f //set this to a default value
    currentAngle += (currentLocation - nextLocation ) * 180.0f / self.bounds.size.width;
    
    // and update the view positions
    [self setCarouselAngle:currentAngle];
    

    Et voila!

    Remarkably simple – I have to learn to just take a step back sometimes and come back to a problem with a clear head.

    Thanks all

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed code on a m-file script in Matlab that communicates with a
We have developed a set of crystal reports (not my idea) that are to
We have a large C code base that has been developed over several decades.
I have a EDM (phoneDB) that models a back-end MSSQL database. I've developed a
I have developed a simple API to allow communication between my Android/iPhone apps and
I have developed web application which uses JasperReports for reporting purpose. In that I
I have developed a C# script that opens an XLS file, parses it and
I have developed a windows phone app that sends notification to users. There is
I have developed a simple library in Ruby and need to use this in
I have developed a web service and host it on my server and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.