2

私はXcodeを学んでいて、ボタンをコードの一部に更新する方法などを考えていました。画面上のランダムな場所に写真を配置していますが、ボタンを押して別のランダムな場所に再配置できるようにしたいので、どんな入力でも大歓迎です。ありがとう。これは私のコードです。ViewController.m

- (void)viewDidLoad
{
int xValue = arc4random() % 320;
int yValue = arc4random() % 480;


UIImageView *imgView = [[UIImageView alloc] initWithFrame:CGRectMake(xValue, yValue, 70, 30)];
NSString *imgFilepath = [[NSBundle mainBundle] pathForResource:@"clubs-2-150" ofType:@"jpg"];
UIImage *img = [[UIImage alloc] initWithContentsOfFile:imgFilepath];
[imgView setImage:img];
[self.view addSubview:imgView];


[super viewDidLoad];   
}
4

1 に答える 1