2011-12-08 16 views
-2

ActionSheetでPickerViewを作成しようとしました。コードはXコードで問題ありませんが、実行して「ボタン」を押すとクラッシュします。UIPickerView&ActionSheet

ありがとうございます。

ここでここで.hファイル

#import <UIKit/UIKit.h> 

@interface UIPickerView_ActionSheetViewController : UIViewController <UIActionSheetDelegate, UIPickerViewDelegate> 
{ 
    IBOutlet UIButton *button; 
} 

@property (nonatomic, retain) UIButton *button; 

- (IBAction)buttonPressed; 

@end 

int型RETVAL = UIApplicationMain(argcの、ARGV、ゼロ、ゼロ)の.mファイル

#import "UIPickerView_ActionSheetViewController.h" 

@implementation UIPickerView_ActionSheetViewController 

@synthesize button; 

- (IBAction)buttonPressed 
{ 
    UIActionSheet *menu = [[UIActionSheet alloc] initWithTitle:@"currentData" 
                delegate:self 
             cancelButtonTitle:@"Done" 
            destructiveButtonTitle:@"Cancel" 
             otherButtonTitles:nil]; 


    UIPickerView *pickerView = [[UIPickerView alloc]initWithFrame:CGRectMake(0,40,480,200)]; 

    pickerView.delegate = self; 
    pickerView.showsSelectionIndicator = YES;  

    [menu addSubview:pickerView]; 
    [menu showInView:self.view]; 
    [menu setBounds:CGRectMake(0,0,480, 320)]; 

    [pickerView release]; 
    [menu release]; 
} 

- (void)dealloc 
{ 
    [button release]; 
    [super dealloc]; 
} 

- (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. 
} 

- (void)viewDidUnload 
{ 
    self.button=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 (interfaceOrientation == UIInterfaceOrientationPortrait); 
} 

@end 

クラッシュです;クラッシュ情報が

#0 0x9631817a in __kill() 
#1 0x9631816c in kill$UNIX2003() 
#2 0x963aa879 in raise() 
#3 0x963c09b8 in abort() 
#4 0x9619dfda in __gnu_cxx::__verbose_terminate_handler() 
#5 0x00f1c23b in _objc_terminate() 
#6 0x9619c17a in __cxxabiv1::__terminate() 
#7 0x9619c1ba in std::terminate() 
#8 0x9619c2b8 in __cxa_throw() 
#9 0x00f1c416 in objc_exception_throw() 
#10 0x00dca0bb in -[NSObject(NSObject) doesNotRecognizeSelector:]() 
#11 0x00d39966 in ___forwarding___() 
#12 0x00d39522 in __forwarding_prep_0___() 
#13 0x0001a4fd in -[UIApplication sendAction:to:from:forEvent:]() 
#14 0x000aa799 in -[UIControl sendAction:to:forEvent:]() 
#15 0x000acc2b in -[UIControl(Internal) _sendActionsForEvents:withEvent:]() 
#16 0x000ab7d8 in -[UIControl touchesEnded:withEvent:]() 
#17 0x0003eded in -[UIWindow _sendTouchesForEvent:]() 
#18 0x0001fc37 in -[UIApplication sendEvent:]() 
#19 0x00024f2e in _UIApplicationHandleEvent() 
#20 0x01001992 in PurpleEventCallback() 
#21 0x00da9944 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__() 
#22 0x00d09cf7 in __CFRunLoopDoSource1() 
#23 0x00d06f83 in __CFRunLoopRun() 
#24 0x00d06840 in CFRunLoopRunSpecific() 
#25 0x00d06761 in CFRunLoopRunInMode() 
#26 0x010001c4 in GSEventRunModal() 
#27 0x01000289 in GSEventRun() 
#28 0x00028c93 in UIApplicationMain() 
#29 0x00001c09 in main (argc=1, argv=0xbfffef8c) at main.m:14 

多分これは助けることができる

#import <UIKit/UIKit.h> 

int main(int argc, char *argv[]) 
{ 
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 
    int retVal = UIApplicationMain(argc, argv, nil, nil); 
    [pool release]; 
    return retVal; 
} 

より

Attaching to process 606. 
2011-12-10 06:37:08.456 UIPickerView_ActionSheet[606:207] -[UIPickerView_ActionSheetViewController DatePickerView]: unrecognized selector sent to instance 0x602dfb0 
2011-12-10 06:37:08.458 UIPickerView_ActionSheet[606:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPickerView_ActionSheetViewController DatePickerView]: unrecognized selector sent to instance 0x602dfb0' 
*** Call stack at first throw: 
(
    0 CoreFoundation      0x00dc85a9 __exceptionPreprocess + 185 
    1 libobjc.A.dylib      0x00f1c313 objc_exception_throw + 44 
    2 CoreFoundation      0x00dca0bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187 
    3 CoreFoundation      0x00d39966 ___forwarding___ + 966 
    4 CoreFoundation      0x00d39522 _CF_forwarding_prep_0 + 50 
    5 UIKit        0x0001a4fd -[UIApplication sendAction:to:from:forEvent:] + 119 
    6 UIKit        0x000aa799 -[UIControl sendAction:to:forEvent:] + 67 
    7 UIKit        0x000acc2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527 
    8 UIKit        0x000ab7d8 -[UIControl touchesEnded:withEvent:] + 458 
    9 UIKit        0x0003eded -[UIWindow _sendTouchesForEvent:] + 567 
    10 UIKit        0x0001fc37 -[UIApplication sendEvent:] + 447 
    11 UIKit        0x00024f2e _UIApplicationHandleEvent + 7576 
    12 GraphicsServices     0x01001992 PurpleEventCallback + 1550 
    13 CoreFoundation      0x00da9944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52 
    14 CoreFoundation      0x00d09cf7 __CFRunLoopDoSource1 + 215 
    15 CoreFoundation      0x00d06f83 __CFRunLoopRun + 979 
    16 CoreFoundation      0x00d06840 CFRunLoopRunSpecific + 208 
    17 CoreFoundation      0x00d06761 CFRunLoopRunInMode + 97 
    18 GraphicsServices     0x010001c4 GSEventRunModal + 217 
    19 GraphicsServices     0x01000289 GSEventRun + 115 
    20 UIKit        0x00028c93 UIApplicationMain + 1160 
    21 UIPickerView_ActionSheet   0x00001cf9 main + 121 
    22 UIPickerView_ActionSheet   0x00001c75 start + 53 
) 
terminate called after throwing an instance of 'NSException' 
Current language: auto; currently objective-c 
これは、あなたがどこかにあなたがあなたのビューコントローラのインスタンスにメッセージ DatePickerViewを送信していることを伝え何
+0

クラッシュの詳細と受け取ったクラッシュログを含めてください。 – jrturton

+0

@jrturtonご協力いただきありがとうございます。まだ画像をアップロードできません。クラッシュ情報の最後の部分をご覧ください。 – Welbin

+0

別のホストにアップロードされた写真へのリンクを投稿します。 'int retVal = ...'でクラッシュしたことを知っていることはまったく役に立たない。それは文字どおり_可能です。 –

答えて

0
[UIPickerView_ActionSheetViewController DatePickerView]: unrecognized selector sent to instance 0x602dfb0 

それを認識しません。

私は上記のコードのどこにでもそのような呼び出しを見ることができないので、プロジェクト内の別のファイルにあるか、またはインターフェイスビルダーで古いか名前が変更されたコンセント接続を持っています。このコードまたは一部のリソースを他の場所からコピーした場合は、実際の要件に合わせて更新する必要があります。

+0

ご協力いただきありがとうございます。上記のコードは大丈夫です、私はちょうど新しいプロジェクトを作成し、同じコードをコピーした、それは働いた。すべてのファイルには奇妙なエラーであるDatePickerViewはありません。 – Welbin