私のハングアップは、配列を作成してボタンを渡し、forループを使用して各ボタンをビューに配置します。彼らは両方が同じCGRectMakeを通過するので、彼らは同じポジションにあることを知っています。しかし、私はこのコードで画面上に何かを置くことはできませんが、エラーを返さないにもかかわらず、なぜ私が困惑してしまっています。基本的なObjective-C配列 'for'ループアシスタント
誰もが何か提案がありますか?ありがとう!
- (void)practiceMethod{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Practice Method has begun" message:@"Alert" delegate: self cancelButtonTitle:@"Close" otherButtonTitles: nil];
//[alert show];
[alert release];
float i=0;
CGRect applicationFrame = [[UIScreen mainScreen] applicationFrame];
UIImage *buttonGraphic = [UIImage imageNamed:@"1.png"];
UIButton *buttonOne = [[UIButton alloc] initWithFrame:applicationFrame];
UIButton *buttonTwo = [[UIButton alloc] initWithFrame:applicationFrame];
buttonArray = [[NSArray alloc] initWithObjects:buttonOne, buttonTwo,nil];
for (i = 0; i > [buttonArray count]; i++) {
UIButton *tempElement = [buttonArray objectAtIndex:i];
tempElement.frame = CGRectMake(140, 230, 50, 50);
[tempElement setBackgroundImage:buttonGraphic forState:UIControlStateNormal];
[self addSubview:tempElement];
}
}
1人:私はばかです。 2:ありがとうございます:) –
これらのことが起こります。私の最も一般的な 'for 'の間違いは' for unsigned int i = arrayLength-1; i> 0; -i); ' :D –