gpt4 book ai didi

ios - NSInvalidArgumentException : unrecognized selector sent to instance

转载 作者:行者123 更新时间:2023-12-01 17:17:34 24 4
gpt4 key购买 nike

当我运行我的应用程序时,我收到此错误:

    Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-
[UIRoundedRectButton copyWithZone:]: unrecognized selector sent to instance
0xcc86970'

为什么我会收到这样的错误?我仔细检查了 IBOutlets 和所有 IBAction 的所有连接。这是我的代码:

菜单 View Controller .h
     @interface MenuViewController : UIViewController
<UITableViewDelegate, UITableViewDataSource>{

}


@property (nonatomic, copy) IBOutlet UITableView * tableView;
@property (nonatomic,copy) IBOutlet UILabel *labelTitle;
@property (nonatomic, copy) IBOutlet UIButton *buttonHome;
@property (nonatomic, copy) IBOutlet UIButton *buttonMap;
@property (nonatomic, copy) IBOutlet UIButton *buttonFavorites;

-(IBAction) pressedHome:(id)sender;
-(IBAction) pressedMap: (id)sender;
-(IBAction) pressedFavorites: (id)sender;

@end

在 MenuViewController.m
 -(IBAction) pressedHome:(id)sender{

MenuViewController * menu =[[MenuViewController alloc]initWithNibName:@"MenuViewController" bundle:nil];
[self.navigationController pushViewController:menu animated:YES];


}

-(IBAction) pressedMap: (id)sender{

MapViewController * map =[[MapViewController alloc]initWithNibName:@"MapViewController" bundle:nil];
[self.navigationController pushViewController:map animated:YES];
}


-(IBAction) pressedFavorites: (id)sender{

FavoritesViewController * favorites =[[FavoritesViewController alloc]initWithNibName:@"FavoritesViewController" bundle:nil];
[self.navigationController pushViewController:favorites animated:YES];
}

提前致谢

最佳答案

删除 copy .发生这种情况是因为 UIButton(和其他 UIControls)不符合 NSCopying协议(protocol),因此复制它们的调用失败。

关于ios - NSInvalidArgumentException : unrecognized selector sent to instance,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12747520/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com