iphone - 为什么单击任何按钮时我的 UIActionSheet 都会崩溃?

标签 iphone ios objective-c uiactionsheet

我的 UIActionSheet 有问题。当我点击任何按钮时它崩溃了。我激活了 NSZombieEnabled。然后,我收到以下错误消息。

[FacebookConfigurationController actionSheet:clickedButtonAtIndex:]: message sent to
deallocated instance 0x84d4430

I put a breakpoint in my method

-(void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger) index

但在它停止之前就崩溃了。这是我的代码,如果你能帮助我

FacebookConfigurationController.h

@interface FacebookConfigurationController: UIViewController<UIActionSheetDelegate,...>

FacebookConfigurationController.m

-(void) LaunchFacebookMenu
{    
     if([Commentaire isEqual:@""])
    {
        NSLog(@"You must enter a comment");
    }
    else
    {
        UIActionSheet *action = [[UIActionSheet alloc] initWithTitle: [self getLanguageValue: @"facebook_popup_title"]
                                                            delegate: self 
                                                   cancelButtonTitle: nil 
                                              destructiveButtonTitle: 
                                 [self getLanguageValue: @"facebook_popup_cancel"]
                                                   otherButtonTitles: 
                                 [self getLanguageValue: @"facebook_popup_userwall"], 
                                 [self getLanguageValue: @"facebook_popup_friendwall"],
                                 [self getLanguageValue: @"facebook_popup_deconect"],nil];
        action.actionSheetStyle =UIActionSheetStyleBlackTranslucent;

        [action showInView:m_CurrentView.view];
        [action release];
    }
}




- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)Index
{ 
    switch (Index) 
    {

        case 0:
        {
            [m_CurrentView dismissModalViewControllerAnimated:YES];   
            break;
        }
        case 1:
        {

         ...
         ...
         ...

最佳答案

您是否释放了您的 FacebookConfigurationController 对象

因为委托(delegate)方法

(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)Index{}

当您释放 “self” 时很快就会被调用。

关于iphone - 为什么单击任何按钮时我的 UIActionSheet 都会崩溃?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13778409/

相关文章:

iphone - 如何删除 UISearchBar 中的工具提示

iphone - 如何添加比 Xcode 中默认广告横幅更大的广告横幅?

ios - Swift协议(protocol)方法使用

ios - 在 Swift 4 中滚动 UITableView 时如何更新 UISlider 值

ios - 关闭 UIImagePickerController 在 IOS 7 中不起作用

objective-c - 在 iPhone 屏幕上绘制罗盘方位

iphone - 将文件添加到 Xcode 项目

iphone - 我们可以使用 UIPickerView 创建自定义单元格吗?

ios - 如何以编程方式添加自动布局 XIB?

iOS:如何检查给定的类是一种 UIViewController 类?