Thank you for a gr开发者_Go百科eat site, I am a biginner in iOS programming and find this site immensely helpfull.
Actualy I have 2 questions:
1) How to transform NSString to NSAray of chars?
2) How to place UIButons randomly on the view when each button.title shows one char from new char array?I would like to do it programaticaly.
To transform NSString to NSAray of chars:
NSMutableArray *characters = [[NSMutableArray alloc] initWithCapacity:[myString length]]; for (int i=0; i < [myString length]; i++) { NSString *ichar = [NSString stringWithFormat:@"%c", [myString characterAtIndex:i ]]; [characters addObject:ichar]; }
2.place UIButons randomly on the view when each button.title shows one char from new char array
UIButton *charButton = [[UIButton alloc]initWithFrame:CGRect(<Your required frame>)];
charButton.titleLabel.text = [characters objectAtIndex:<ur required value>];
[self.view addsubView:charbutton]
精彩评论