来自评论的更新:
雅它为我工作。犯了一个愚蠢的错误:-(在viewDidLoad中,我为删除按钮调用了一个backAction方法而不是showDeleteActionSheet。这就是它造成这个麻烦的原因。非常感谢
我有一个 UIScrollView,其中添加了多个 UIView。我想通过使用 UIActionSheet 从 UIScrollView 中删除特定视图。但它不起作用..
.h file
-------
@interface myScrollViewController : UIViewController <UIScrollViewDelegate,UIActionSheetDelegate>
{
UIScrollView *holdSlideScrollView;
UIImageView *editPaperView;
}
@property (nonatomic, strong) UIScrollView *holdSlideScrollView;
@property (nonatomic, strong) UIScrollView *holdSlideScrollView;
- (void) showDeleteActionSheet;
@end
.m file
———
@implementation SlideViewController
- (void) loadView
{
[super loadView];
for (int i= 0; i < 2; i++)
{
UIImageView *editPaperView = [[UIImageView alloc] initWithFrame:CGRectMake(6.0f+i*320, 4.0f, 307.0f, 409.0f)];
[editPaperView setImage:[UIImage imageNamed:@"paper.png"]];
editPaperView.userInteractionEnabled = YES;
editPaperView.tag = i;
UIButton *deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
[deleteButton setAlpha:0.8f];
[deleteButton setFrame:CGRectMake(265.0f, 378.0f, 30.0f, 30.0f)];
[deleteButton setImage:[UIImage imageNamed:@"ps_delete.png"] forState:UIControlStateNormal];
//[deleteButton setImage:[UIImage imageNamed:@“delete_bplushigh.png"] forState:UIControlStateHighlighted];
[deleteButton addTarget:self action:@selector(showDeleteActionSheet) forControlEvents:UIControlEventTouchUpInside];
[editPaperView addSubview:deleteButton];
[holdSlideScrollView addSubview:editPaperView];
}
[self.view addSubview:holdSlideScrollView];
}
- (void) showDeleteActionSheet
{
UIActionSheet *popupDeleteActionSheet = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete" otherButtonTitles:nil];
popupDeleteActionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[popupDeleteActionSheet showInView:self.view];
//popupDeleteActionSheet = nil;
}
@end
这有什么问题?请帮我!