UIAlertView
의 범주를 만들고 대표 메서드 willPresentAlertView
을 (를) 재정의했지만 범주에서 내 메서드가 실행되지 않습니다.범주의 대리자 메서드를 재정의하는 방법?
샘플 코드 :
@interface UIAlertView (CustomAlert)
@end
@implementation UIAlertView (CustomAlert)
- (void)willPresentAlertView:(UIAlertView *)alertView1
{
for (UIView *sub in [alertView1 subviews])
{
if([sub class] == [UIImageView class])
{
((UIImageView *)sub).image=nil;
((UIImageView *)sub).backgroundColor = [UIColor blackColor];
}
}
[alertView1.layer setBorderColor:[[UIColor whiteColor] CGColor]];
[alertView1.layer setCornerRadius:0];
[alertView1.layer setBorderWidth:2];
}
@end
왜 카테고리에서 사용 하시겠습니까? 목적은 무엇입니까? –
대리자 메서드는 대리자 개체 인 원본 개체 hav에서 실행되며 대리자 개체가 원하는 방식으로 실행될 메서드 만 시작합니다. 추가 기능을 원하면 카테고리 또는 하위 클래스에 작성할 수 있습니다. 델리게이트 메소드를 구현하려면 객체 클래스를 위임 할 수 있습니다. –
경고보기를 자체 대리인으로 설정 했습니까? – jrturton