当我运行我的应用程序时,我得到这个错误:
    Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-
     [UIRoundedRectButton copyWithZone:]: unrecognized selector sent to instance
     0xcc86970'为什么会出现这样的错误?我小心翼翼地检查了IBOutlets e IBAction的所有连接。这是我的代码:
MenuViewController.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];
   }提前感谢
发布于 2012-10-05 21:50:25
卸下copy。这是因为UIButton (和其他UIControls)不符合NSCopying协议,所以复制它们的调用失败。
发布于 2012-10-05 21:48:26
删除以下属性的copy
@property (nonatomic) IBOutlet UITableView * tableView;
@property (nonatomic) IBOutlet UILabel *labelTitle;
@property (nonatomic) IBOutlet UIButton *buttonHome;
@property (nonatomic) IBOutlet UIButton *buttonMap;
@property (nonatomic) IBOutlet UIButton *buttonFavorites;https://stackoverflow.com/questions/12747520
复制相似问题