“ActionSheet”的本地声明隐藏了实例变量

时间:2012-03-08 23:10:16

标签: iphone ios uiactionsheet

为这三个陈述获取三条警告信息

ActionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;

[ActionSheet showInView:self.view ];

[ActionSheet release]; 

'ActionSheet'的本地声明隐藏了实例变量

@property (nonatomic, retain) UIActionSheet *ActionSheet;

@synthesize ActionSheet;


-(void)displayActionSheet:(id)sender

{

UIActionSheet *ActionSheet = [[UIActionSheet alloc] 
                              initWithTitle:@"Language Options"
                              delegate:nil
                              cancelButtonTitle:@"Cancel"
                              destructiveButtonTitle:nil
                              otherButtonTitles:@"Devanagari", @"English", nil];

ActionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;

[ActionSheet showInView:self.view ];

[ActionSheet release];

}

知道出了什么问题。

1 个答案:

答案 0 :(得分:1)

首先:变量不是用大写写的。请重命名您的actionSheet变量。

第二:您的属性与您的本地变量(在您的情况下为ActionSheet)具有相同的名称。如果要将actionSheet保存在成员变量中,请删除导致该函数的UIActionSheet*

-(void)displayActionSheet:(id)sender
{
    ActionSheet = [[UIActionSheet alloc] 
                                  initWithTitle:@"Language Options"
                                  delegate:nil
                                  cancelButtonTitle:@"Cancel"
                                  destructiveButtonTitle:nil
                                  otherButtonTitles:@"Devanagari", @"English", nil];
    ActionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
    [ActionSheet showInView:self.view ];
    [ActionSheet release];
}