某些东西工作不正常,我无法理解为什么这不能加载我的其他笔尖,这目前有效
#pragma mark - Flipside View
- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller
{
[self dismissModalViewControllerAnimated:YES];
}
- (IBAction)showInfo:(id)sender
{
FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideViewController" bundle:nil];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
}
虽然我在同一MainViewController.m
完成了同样的事情,并且在做这件事时没有成功
#pragma mark - News View
- (void)newsViewControllerDidFinish:(NewsViewController *)controller
{
[self dismissModalViewControllerAnimated:YES];
}
- (IBAction)showNews:(id)sender
{
NewsViewController *controller = [[NewsViewController alloc] initWithNibName:@"NewsViewController" bundle:nil];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
}
所以我认为我的头文件出现了问题,看起来像这个
#import "FlipsideViewController.h"
#import "NewsViewController.h"
@interface MainViewController : UIViewController <FlipsideViewControllerDelegate, NewsViewControllerDelegate>
- (IBAction)showInfo:(id)sender;
- (IBAction)showNews:(id)sender;
@end
我无法理解为什么它不起作用,任何帮助都会受到赞赏。
输出错误:
此GDB配置为“x86_64-apple-darwin”。附加到 过程2147。 2011-07-08 12:24:09.845 Danny [2147:ef03] - [NewsViewController setDelegate:]:无法识别的选择器 发送到实例0x68a62b0 2011-07-08 12:24:09.847 Danny [2147:ef03] *终止应用 由于未被捕获的例外 'NSInvalidArgumentException',原因: ' - [NewsViewController setDelegate:]: 无法识别的选择器发送到实例 0x68a62b0' * 第一次抛出调用堆栈: (0xf8a600 0x112252e 0xf8d550 0xeeb4cf 0xeeb292 0x2a36 0xf8bd78 0x18cc5 0x18c5a 0xbdbd4 0xbe09d 0xbd368 0x3e004 0x3e22d 0x24990 0x181a7 0x1369886 0xf59d11 0xebbc9b 0xeba4b1 0xeb993c 0xeb9868 0x1367fef 0x13680b4 0x160c4 0x2009 0x1f75) 终止叫做throwharedlibrary apply-load-rules all 当前语言:auto;目前客观的c (GDB)
答案 0 :(得分:0)
视图控制器的委托方法是什么?检查委托方法的声明是否相同。确保已正确设置代理
答案 1 :(得分:0)
试试这个:
- (IBAction)showNews:(id)sender
{
NewsViewController *controller = [[NewsViewController alloc] initWithNibName:@"NewsViewController" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
}
在新闻视图中,而不是写
[self.delegate newsViewControllerDidFinish:self];
你应该写:
[self dismissModalViewControllerAnimated:YES];
那应该可以解决你的问题。我没有看到写出额外代表的重点,他们通常不会给你任何优势(在这样的场景中),当你只能让视图控制器解雇时。