我在滾動視圖中添加了圖像。長按我給所有圖像擺動動畫。 當我們卸載任何類似的應用程序時,我想在iphone中顯示每個圖像右上角的刪除按鈕。在擺動圖像上顯示刪除按鈕並刪除該特定圖像
- (void)startWobble {
for (UIView *imgView in viewsInScrollView) {
UIButton *deleteImgButton = [[UIButton alloc] initWithFrame:CGRectMake(55,-7,12,12)];
[deleteImgButton setImage:[UIImage imageNamed:@"close_icon.png"] forState:UIControlStateNormal];
[deleteImgButton addTarget:self action:@selector(deleteImage:) forControlEvents:UIControlEventTouchUpInside];
[imgView addSubview:deleteImgButton];
imgView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-5));
[UIView animateWithDuration:0.20
delay:0.0
options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse)
animations:^ {
imgView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(5));
}
completion:NULL
];
}
}
-(void)deleteImage : (id)sender {
NSLog(@"Delete Image");
}
這裏的選擇器不叫....我怎麼解決這個..?
你可以顯示這個標題檔案?你在頭文件中聲明瞭deleteImage方法嗎? – giorashc
是的,我已經宣佈它... – Pallavi
當我添加動畫到圖像視圖和添加按鈕圖像視圖可能是它禁用用戶交互 http://stackoverflow.com/questions/12354919/add-selector-to-button-on -uiscrollview-views-added-dynamically – Pallavi