1

アプリケーションを実行すると、次のエラーが発生します。

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

なぜこのようなエラーが発生するのですか?IBOutletsとすべての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];
   }

前もって感謝します

4

2 に答える 2

12

を取り外しますcopy。これは、UIButton (および他の UIControls) がNSCopyingプロトコルに準拠していないために発生しているため、それらをコピーする呼び出しが失敗します。

于 2012-10-05T13:50:25.043 に答える
1

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;
于 2012-10-05T13:48:25.997 に答える