Solved

# How do I display 10 buttons in a circle in objective c using for loop?

Posted on 2012-09-01
563 Views
Need a solution and please explain each line if you could. Many thanks.
0
Question by:charmingduck

LVL 14

Expert Comment

Excuse me; what do you mean by displaying 10 buttons in a circle!?
0

Author Comment

in a round shape
0

Author Comment

like putting 10 apples around a round table.
0

LVL 14

Assisted Solution

For doing that you have to calculate the coordinates of 10 points placed on a circle with equal spaces. This is a calculus problem (finding 10 points on equation X^2 + Y^2 = K where the distance between each neighbor points is exactly the same)
iOS does not have a method which finds the points for you. You have to do it manually.
You may also try to do this in Interface Builder but unfortunately you cannot determine the precise position of each button.
0

Author Comment

do you know how to do it with a for loop?
0

LVL 14

Expert Comment

As I said you have to first calculate 10 points coordinates. afterwards the for loop is quite easy then.
0

Author Comment

I think there is a smart way to draw this circle in code rather than entering the cords manually?
0

LVL 14

Accepted Solution

No I did not suggest you to calculate the coordinates manually. I meant you should write a function that take e.g. 3 parameters: CIRCLE_CENTER, CIRCLE_RADIUS, NO_OF_POINTS which utilizes a calculus-based algorithm to calculate the coordination of each point then return all those in an array. Afterwards you will write a for-loop to create 10 buttons by using the coordinates in that array.
0

## Featured Post

Ever wanted to watch videos in your computer from the bed without the need of standing up and shutting down the computer?  Is your computers operating system Windows XP, Windows Vista or Windows 7?  Do you own a iOS device? If all the answers were y…
There is a security feature on iOS devices that is nearly impenetrable when it has been activated.  This article will provide some possible solutions as well as necessary steps to take to ensure you do not end up with a locked device.
This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…