2013-04-20 1 views
0

게시물을보고 할 수 있어야하는 앱을 만들고 있습니다. 사용자가 보고서 단추를 누르면 작업 시트가 필요합니다. 이 내 코드입니다 :작업 오류 : @ selectlector in app

[self.avatarImageView.profileButton addTarget:self action:@selector(didTapReportButtonAction:) forControlEvents:UIControlEventTouchUpInside]; 

여기에 didTapReportButtonAction 코드 : 지금 보고서 버튼을 누르려고 할 때

- (void)didTapReportButtonAction:(UIButton *)button { 
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Title" delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Destructive" otherButtonTitles:@"Other1", @"Other2", nil]; 
    actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent; 
    [actionSheet addButtonWithTitle:@"Add"]; 
    [actionSheet showInView:[UIApplication sharedApplication].keyWindow]; 
} 

그러나 아무 일도 발생하지 않습니다. 누군가 나를 도와 줄 수 있습니까?

+1

이는 엑스 코드의 문제가 아닙니다. –

답변

1

avatarImageView가 UIImageView 인 경우, userinteraction 속성은 기본적으로 false입니다. 이것은 이벤트가 호출되지 않는다는 것을 의미합니다.

avatarImageView.userInteraction = YES

1

당신이 있는지 시도 할 수 있는지 확인 :

[actionSheet showInView:self.view];