두 개의 단추가있는 UIAlertView의 인스턴스를 만들고 클래스 (.h)의 인터페이스 파일에서 대리자를 설정했지만 단추를 클릭해도 응답을받지 못합니다. 를 취할 수 없습니다 여전히UIAlertView 대리자 메서드가 iOS 5.1에서 응답하지 않습니다.
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@"UIAlertView delegate works");//this line too isnt displayed
NSString *title=[ alertView buttonTitleAtIndex:buttonIndex ];
if ([title isEqualToString:@"OK"]) {
NSLog(@"OK Pressed");
}//i want to create something like this
} 나는 위의 모든 코드를했지만 :
//myClass.h
@interface MainMenu : UIViewController<UIAlertViewDelegate>
-(IBAction)secondAct:(id)sender;
그리고 구현
-(IBAction)secondAct:(id)sender
alert = [[UIAlertView alloc] initWithTitle:@"Dear User"
message:@"Your Request Will be Sent To Security"
delegate:nil
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
[alert show];
[alert autorelease];
}
및 대리자 방법 : 여기 내 코드입니다 동작. 클릭 한 버튼 중 어느 것이 든 경고를 보냅니다. 이 코드에 어떤 문제가 있습니까? PeterG. 친애하는 답변
은 delegate:self
와 delegete:nil
을 변경 주석 그것은 작동합니다.
대리인 : nil이 작동하지 않습니다 ... 대리인으로 변경 : 자기 –
이전에 시도했습니다. 오류가 발생했습니다. – ilhnctn
@PeterG. 죄송합니다. – ilhnctn