X-Code 4.2を使用してアプリケーションを構築し始めたばかりです。私は単一のビューのアプリケーションテンプレートでアプリケーションを作成しました。ボタンを押した後Main.mでクラッシュする
私は画像、ラベル、ボタンを含む単純なVCであるMainIconViewControllerを作成しました。私は私のmainViewControllerビューにMainIconViewControllerビューを追加し、ボタンが押されたとき、私は言うMain.mでクラッシュを取得:
- [__ NSCFType mainButtonPressed:]:認識されていないセレクタはインスタンス0xb867ba0
ラインでに送信クラッシュが発生しMain.mがされています。今のbuttonPressed
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
:完全に空です。
これを修正する方法はありますか?
これを再テストするための全く新しいプロジェクトを作成しようとしました。私はプロジェクトを作成し、単一のボタンを含むviewControllerサブクラスを作成しました。次に、メインビューコントローラでこのビューのインスタンスを作成し、それをビューに追加します。ボタンを押すと、前と同じようにアプリケーションがクラッシュします。
EDIT: はここにすべてのコードです:
//MainIconViewController.h
@protocol MainIconViewControllerDelegate <NSObject>
-(void) openFileNamed:(NSString *)name;
-(void) createNewFile;
@end
#import <UIKit/UIKit.h>
@interface MainIconViewController : UIViewController {
}
@property (assign) id <MainIconViewControllerDelegate> delegate;
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
- (void)mainButtonPressed:(id)sender;
@end
//////////////////////////////
//MainIconViewController.m
#import "MainIconViewController.h"
@implementation MainIconViewController
@synthesize titleLabel;
@synthesize imageView;
@synthesize delegate;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)viewDidUnload
{
[self setTitleLabel:nil];
[self setImageView:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
- (void)mainButtonPressed:(id)sender{
}
@end
実際には、main()にクラッシュがありませんでした。ボタンアクションコードを投稿してください。 – zaph
ボタンアクションには何もありません – Brodie