2009-04-07 23 views
5

Tôi đang gặp sự cố sau khi thêm người gửi: (id) để tôi có thể xác định nút nào được gọi. Khi thiết lập như cũ toggleView3 cũ nó hoạt động hoàn hảo. Sự cố xảy ra khi detailView được chuyển về docView.NSInvalidArgumentException

'NSInvalidArgumentException', reason: '*** -[RootViewController toggleView3]: unrecognized selector sent to instance 0x524a00' 2009-04-07 12:29:44.421 eTarot[11405:20b] Stack:

-(IBAction)toggleView3:(id)sender{ 


    if (detailViewController == nil) { 
     [self loadDetailViewController]; 
    } 

    UIView *docView = docViewController.view; 
    UIView *detailView = detailViewController.view; 

    [UIView beginAnimations:nil context:NULL]; 
    [UIView setAnimationDuration:1]; 
    [UIView setAnimationTransition:([docView superview] ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft) forView:self.view cache:YES]; 

    if ([docView superview] != nil) { 
     [detailViewController viewWillAppear:YES]; 
     [docViewController viewWillDisappear:YES]; 
     [docView removeFromSuperview]; 

     [self.view addSubview:detailView]; 
     [self.view insertSubview:detailNavigationBar aboveSubview:detailView]; 
     [docViewController viewDidDisappear:YES]; 
     [detailViewController viewDidAppear:YES]; 

    } else { 
     [docViewController viewWillAppear:YES]; 
     [detailViewController viewWillDisappear:YES]; 
     [detailView removeFromSuperview]; 
     [detailNavigationBar removeFromSuperview]; 
     [self.view addSubview:docView]; 
     [detailViewController viewDidDisappear:YES]; 
     [docViewController viewDidAppear:YES]; 
    } 
    [UIView commitAnimations]; 
} 
+0

bạn có thể đăng mã gọi toggleView3 không? – cobbal

Trả lời

13

Bạn đang gửi chế độ xem thư toggleView3 khi tên đúng của bộ chọn là toggleView3: - tức là, có dấu hai chấm và đối số. Chúng có thể trông giống bạn, nhưng chúng hoàn toàn khác với Objective-C.

+0

Cảm ơn Chuck. Rõ ràng, một khi nó chỉ ra :) – Alan

2

ngoại lệ đó có nghĩa là ứng dụng của bạn đang kêu gọi toggleView3 mà không có sự: đối số người gửi ở đâu đó. Vì phương thức mới của bạn yêu cầu một đối số, nó giống như gọi một phương thức chưa từng tồn tại.

Nếu bạn xem qua dấu vết ngăn xếp trong trình gỡ lỗi, nó sẽ khá rõ ràng khi nó đến từ đâu. Có lẽ có một cảnh báo trong kết quả xây dựng.

Các vấn đề liên quan