私はiPhone開発には初めてです。ボタンをクリックしてiPhoneをアレイアップデートする
ボタンをプログラムでクリックすると、IMAGEVIEWの新しいイメージがUIViewに表示されます。私はいくつかのコンテナに画像を保存し、後でそれらを使用したいと思います。
ここでは、UIGraphicsで画像を作成するためのソースコードを示します。
画像が表示されているがif ([shape isEqualToString:@"Rectangle"])
{
UIGraphicsBeginImageContext(CGSizeMake(100.0, 100.0));
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGRect main =CGRectMake(15.0, 15.0, 70.0, 30.0);
CGContextFillRect(context, main);
CGRect topSeat1 = CGRectMake(15.0, 0.0, 15.0, 13.0);
CGRect topSeat2 = CGRectMake(42.5, 0.0, 15.0, 13.0);
CGRect topSeat3 = CGRectMake(70.0, 0.0, 15.0, 13.0);
CGRect leftSeat = CGRectMake(0.0, 22.5, 13.0, 15.0);
CGRect rightSeat = CGRectMake(87.0, 22.5, 13.0, 15.0);
[[UIColor redColor]set];
//UIRectFill(main);
UIRectFill(topSeat1);
UIRectFill(topSeat2);
UIRectFill(topSeat3);
UIRectFill(leftSeat);
UIRectFill(rightSeat);
UIRectFrame(main);
[[UIColor blackColor]set];
UIRectFrame(topSeat1);
UIRectFrame(topSeat2);
UIRectFrame(topSeat3);
UIRectFrame(leftSeat);
UIRectFrame(rightSeat);
UIImage * image = [[UIImage alloc]init];
image = UIGraphicsGetImageFromCurrentImageContext();
myImage=[[UIImageView alloc]initWithImage:image];
UIGraphicsEndImageContext();
[self.view addSubview:myImage];
[myImage setUserInteractionEnabled:YES];
[arrayOfImages addObject:myImage];
}
が、私はもう一度ボタンをクリックすると、別の画像が表示されますが、UIViewの上の1年上のは静的になり、私はそれに何もできません。
私はいくつかのコードをお勧めします。
私が尋ねるすべては次のとおりです。
すべてのボタンの上にコンテナがUIImageViewsを移入または更新されますクリックするように、それらを格納する方法。
後で復元する方法。
を助けた
希望が完了したらimagesArrayを解放することを忘れ[imagesArrayリリース]ユーザーのブログを促進するためのフラグ付き –