PageViewController.h
paintingOptions = [[UIButton alloc] initWithFrame:CGRectMake(200,30,100,100)];
[paintingOptions setTitle:@"Ok" forState:UIControlStateNormal];
[paintingOptions setBackgroundColor:[UIColor blackColor]];
[paintingOptions addTarget:self action:@selector(showPaintingOptions:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:paintingOptions];
-(void) showPaintingOptions: (id) sender {
NSLog(@"Button pressed");
}
有关如何解决的任何提示?
调试:
调试输出只显示(gdb)。 Xcode向我展示了这一行:
PDFViewController.h
- (UIView *)view {
return self.scrollView; }
0x32c37102 <+0014> ldr r1, [pc, #16] (0x32c37114 <-[UIViewController nextResponder]+32>)
但是这个功能在另一个视图控制器中。 所以我有按钮的视图是这个scrollView的子视图。
将PageViewController添加到PDFViewController:
- (void)loadScrollViewWithPage:(int)page
{
if (page < 0)
return;
if (page >= kNumberOfPages)
return;
// replace the placeholder if necessary
PageViewController *controller = [viewControllers objectAtIndex:page];
if ((NSNull *)controller == [NSNull null])
{
//page+1 cause CGPDF indexing starts with 1
controller = [[PageViewController alloc] initWithPageNumberAndUrl:page+1: [chapter urlOnFilesystem]];
[viewControllers replaceObjectAtIndex:page withObject:controller];
[controller release];
}
// add the controller's view to the scroll view
if (controller.view.superview == nil)
{
CGRect frame = scrollView.frame;
frame.origin.x = frame.size.width * page;
frame.origin.y = 0;
controller.view.frame = frame;
[scrollView addSubview:controller.view];
}
}
答案 0 :(得分:1)
从崩溃日志中看起来像 - (void)showPaintingOptions:(id)sender 不在您的目标自己中。请确保。