2011-12-07 9 views
0

私は文をボックス/フレームに分割する方法 - 単語ごとに?

//Putting the sentence into array 

NSString *list = (@"A book costs £50., Ken has saved £45., How much more does he need to save to buy the book?"); 
NSArray *listItems = [list componentsSeparatedByString:@", "]; 

のようなものを試してみましたが、結果は私が欲しいものではなかったです。私は各フレームに単語が含まれています。例えば、[A] [書籍] [コスト] ...など

// to create a frame 

    CGRect frame= CGRectMake(50, 60, 50, 50); 
    comp *newBox = [[comp alloc] initWithFrame:frame ]; 
    [self.view addSubview:newBox]; 
    newBox.backgroundColor=[UIColor blueColor] 
    This frame work fine, i just need to put the word in to each frame 

答えて

0

素晴らしいこの

NSString *list = (@"A book costs £50. Ken has saved £45. How much more does he need to save to buy the book?"); 
NSArray *listItems = [list componentsSeparatedByString:@" "]; 
+0

をお試しください!なぜ私はそれについて考えなかったのですか?各単語を別のフレームにどのようにループするか、もう1つ質問してください。なぜなら、私が今得たものは、10個のボックスに全文が入っているからです。 – raymond

+0

私は問題を抱えています:)([A、book、costs、...])[(A、book、costs、...)ありがとう – raymond

関連する問題