我有一个我不明白的错误。
我有一门课来帮助打印作业:
//.h
@interface PrintDelegate : NSObject <UIPrintInteractionControllerDelegate, UIAlertViewDelegate>
@property (weak, nonatomic) FFDetailViewController* controller;
@property (strong, nonatomic) NSMutableData* pdf;
@property (assign) int pageCount;
@property (strong, nonatomic) NSArray* fields;
@property (weak, nonatomic) UIPrintInteractionController* printController;
- (id) initWithPageCount:(int)pc forFields:(NSArray*)flds Controller:(FFDetailViewController*)ctlr;
- (int) printFromButton: (UIBarButtonItem*) btn;
- (void) makePDF;
- (void) shift:(PixelShiftDirection)dir pixelCount:(int)amt;
- (void) adjustFields;
- (void) onPrintComplete;
@end
打印完成后,我会显示一条警报,询问用户是否要调整打印输出(并再次打印)。
//.m
- (void) onPrintComplete
{
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Printing Complete" message:@"Would you like to adjust the field positions?" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Adjust", nil];
[alert show];
}
- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString* clickedButton = [alertView buttonTitleAtIndex:buttonIndex];
if ([clickedButton isEqualToString:@"Adjust"])
{
[self adjustFields];
}
}
当我点击警报中的任一按钮时,我会收到类似于此的错误:
-[__NSArrayM alertView:clickedButtonAtIndex:]: unrecognized selector sent to instance
接收错误选择器的对象总是很奇怪,(我也见过NSCFArrayM 和 __NSMallocBlock)。选择器是来自 UIAlertViewDelegate 协议的方法。我不明白为什么选择器被发送到一些不正确的对象而不是我的 PrintDelegae 对象。
谢谢