调用actionSheet clickedButtonAtIndex发生崩溃

时间:2012-05-16 04:27:29

标签: iphone ios

我想将动作表放到重用类中,但是当我单击操作表时,应用程序崩溃并且错误是EXC_BAD_ACCESS。

MOTestAction.h

#import <Foundation/Foundation.h>

@interface MOTestAction : NSObject<UIActionSheetDelegate>
{
    UIActionSheet * actionSheet;
}
- (id) initWithAction;
- (void) showInView:(UIView *) view;
@end

MOTestAction.m     #import“MOTestAction.h”

@implementation MOTestAction

- (id) initWithAction
{
    self = [super init];

    if (self) {
        actionSheet = [[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"Cancle" destructiveButtonTitle:nil otherButtonTitles:nil, nil];

        }
        return self;
    }

- (void) showInView:(UIView *) view
{
    [actionSheet showInView:view];

}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex;
{

}

@end

来电者:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically 
    MOTestAction * moActionSheet = [[MOTestAction alloc]initWithAction];
    [moActionSheet showInView:self.navigationController.toolbar];


}

0 个答案:

没有答案