objective-c – 如何使用关闭按钮关闭UIActionSheet并避免崩溃?

objective-c – 如何使用关闭按钮关闭UIActionSheet并避免崩溃?,第1张

概述我已阅读另一篇文章( how to dismiss action sheet),我可以使用 [actionSheet dismissWithClickedButtonIndex:0 animated:YES]; 使用关闭按钮关闭uiactionsheet,如下所述: UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle: 我已阅读另一篇文章( how to dismiss action sheet),我可以使用

[actionSheet dismissWithClickedbuttonIndex:0 animated:YES];

使用关闭按钮关闭uiactionsheet,如下所述:

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil                                                          delegate:nil                                                cancelbuttonTitle:nil                                           destructivebuttonTitle:nil                                                otherbuttonTitles:nil];[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];CGRect pickerFrame = CGRectMake(0,40,0);UIPickerVIEw *pickerVIEw = [[UIPickerVIEw alloc] initWithFrame:pickerFrame];pickerVIEw.showsSelectionIndicator = YES;pickerVIEw.dataSource = self;pickerVIEw.delegate = self;[actionSheet addSubvIEw:pickerVIEw];[pickerVIEw release];UISegmentedControl *closebutton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Close"]];closebutton.momentary = YES; closebutton.frame = CGRectMake(260,7.0f,50.0f,30.0f);closebutton.segmentedControlStyle = UISegmentedControlStylebar;closebutton.tintcolor = [UIcolor blackcolor];[closebutton addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged];[actionSheet addSubvIEw:closebutton];[actionSheet dismissWithClickedbuttonIndex:0 animated:YES];[closebutton release];[actionSheet showInVIEw:[[UIApplication sharedApplication] keyWindow]];[actionSheet setBounds:CGRectMake(0,320,485)];

但是,我不知道在哪里放置这一行,假设这将解决我的问题:

[actionSheet dismissWithClickedbuttonIndex:0 animated:YES];

此外,当我单击关闭按钮时,应用程序崩溃,并显示错误消息“PROGRAM RECEIVED ERROR MESSAGE SIGBRT”.我认为我的两个问题是相关的.有帮助吗?

解决方法 只需实现dismissActionSheet并将你的dismiss消息放在那里.

dismissActionSheet方法看起来像这样:

-(voID)dismissActionSheet {   [sheet dismissWithClickedbuttonIndex:0 animated:YES];}
总结

以上是内存溢出为你收集整理的objective-c – 如何使用关闭按钮关闭UIActionSheet并避免崩溃?全部内容,希望文章能够帮你解决objective-c – 如何使用关闭按钮关闭UIActionSheet并避免崩溃?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1056952.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存