Note that there are some explanatory texts on larger screens.

plurals
  1. POAllocating UITextViews in specific positions
    primarykey
    data
    text
    <p>I have a circle at the center of the screen, and I am allocating around this fixed circle (a UIImageView) a series of UIlabels. the number of the labels is given by the number of elements in an NSMutableArray, and the position of the labels depends on the number of labels. I can't give a fixed x and y coordinate to the labels, because the number of labels will vary.</p> <p>I tried using this code:</p> <pre><code>- (void)loadContent{ NSString *filename6 = [[NSUserDefaults standardUserDefaults]objectForKey:@"Setting"]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *groupPath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", filename6]]; NSString *fileContent = [[NSString alloc] initWithContentsOfFile:groupPath]; NSMutableArray* array = [[NSMutableArray alloc] initWithArray:[fileContent componentsSeparatedByString:@", "]]; int arrayCount = array.count; int yCoordinate = (2*M_PI) / arrayCount; int xCoordinate = ; for(int i = 0; i &lt; [array count]; i++){ CGRect textframe = CGRectMake( the xcoordinate, the ycoordinate, 328, 30); NSString *nameOfGroup = [array objectAtIndex:i]; UITextView* theGroupTextLabel; theGroupTextLabel = [[UITextView alloc] initWithFrame: textframe]; [theGroupTextLabel setText: nameOfGroup]; [theGroupTextLabel setTextColor: [UIColor redColor]]; [self.view addSubview:theGroupTextLabel]; //theGroupTextLabel.enabled = NO; theGroupTextLabel.backgroundColor = [UIColor clearColor]; theGroupTextLabel.layer.borderWidth = 3.5f; theGroupTextLabel.layer.borderColor = [[UIColor blackColor] CGColor]; int z; z = z + 1; theGroupTextLabel.tag = z; } } </code></pre> <p>but i am stuck with finding the right equation for the:</p> <pre><code>int yCoordinate = (2*M_PI) / arrayCount; int xCoordinate = ; </code></pre> <p>...coordinates. Any ideas? Is this the right method I am using?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload