0

アクションシートを再利用クラスに入れたいのですが、アクションシートをクリックするとアプリがクラッシュしてエラーが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];


}
4

0 に答える 0