0
버튼을 클릭 할 때 UIButton
및 UImageView
을 자동으로 한 곳에서 다른 곳으로 이동하는 방법. scrollview 내에서 프로그래밍 방식으로 UIButton
및 UIImageView
을 만들었습니다. 그러나 나는 단추를 클릭 할 때 또 UIImage
을 지정하고 버튼을 지정한 위치로 옮기고 싶습니다. 내가 bgImage
및 myButton
그 자리를 제거하고 난 bgImage1
을 원하는 myButton1
이 수정없이 다음 장소로 이동 buttonclicked1
버튼을 클릭하면UIButton 및 UIImageView를 iPhone에서 한 위치에서 다른 위치로 이동하는 방법은 무엇입니까?
여기에 내 코드
if (i==0)
{
bgImage = [[UIImageView alloc] initWithFrame:CGRectMake(20,30+x,100,100)];
bgImage.image = [UIImage imageNamed:@"iphone.png"];
[self.view addSubview:bgImage];
[scrollview addSubview:bgImage];
myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton.frame = CGRectMake(120, 65+x, 70, 30); // position in the parent view and set the size of the button
[myButton setTitle:@"Delete" forState:UIControlStateNormal];
[myButton addTarget:self action:@selector(buttonClicked) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:myButton];
[scrollview addSubview:myButton];
x=x+100;
}
if (i==1)
{
bgImage1 = [[UIImageView alloc] initWithFrame:CGRectMake(20,30+x,100,100)];
bgImage1.image = [UIImage imageNamed:@"iphone.png"];
[self.view addSubview:bgImage1];
[scrollview addSubview:bgImage1];
UIButton *myButton1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton1.frame = CGRectMake(120, 65+x, 70, 30); // position in the parent view and set the size of the button
[myButton1 setTitle:@"Delete" forState:UIControlStateNormal];
[myButton1 addTarget:self action:@selector(buttonClicked1) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:myButton1];
[scrollview addSubview:myButton1];
x=x+100;
}
- (void)buttonClicked1
{
[bgImage removeFromSuperview];
[bgImage release];
bgImage=nil;
myButton.enabled=NO;
myButton.hidden=YES;
}
입니다.
수행 방법. 아무도 나에게 코드 pls 줄. 나는 그것을 움직일 수 없다. 어떻게하는지. Pls 날 도와 줘요.
미리 감사드립니다.
오 감사합니다. 큰. 잘 작동합니다. –