开发者

simple UIButton always crashes my app on touch

i have a strange problem. On my view i have two segmented controls and one button. The segmented controls work perfectly but my button crashes the app when i touch it.

NSLog won't be called anymore.

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");
}

Any hints on how to solve that ?

Debug:

The debug output says nothing but (gdb). Xcode shows me this line:

PDFViewController.h

- (UIView *)view {
    return self.scrollView; }

0x32c37102  <+0014>  ldr    r1, [pc, #16]   (0x32c37114 <-[UIViewController nextResponder]+32>)

But this function is in another view controller. So the view where i have the button in is a subview of this scrollView.

Adding PageViewController to 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];


}
}


From the crash log it looks like -(void) showPaintingOptions: (id) sender is not in your target self. Please make sure that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜