2011-12-08 45 views
-2

我儘量讓與ActionSheet.The代碼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 

這裏是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 

發生崩潰INT retVal的= UIApplicationMain(的argc,argv的,零,無) ;

#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; 
} 

崩潰信息

#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 

也許這可以幫助更多

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 
+0

請包括飛機墜毀時收到的細節和任何崩潰日誌。 – jrturton

+0

@jrturton謝謝你的幫助。我還無法上傳圖片,請查看最後一部分的崩潰信息。 – Welbin

+0

我會發布一張鏈接,上傳到不同主機的照片。知道它在'int retVal = ...'上崩潰是完全沒用的。它可以字面上是_anything_。 –

回答

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

這告訴你的是,地方您要發送的消息DatePickerView到您的視圖控制器實例,但它不承認它。

我不能在代碼中看到這樣的調用上面的任何地方,因此無論是在項目中的不同的文件,或者你在Interface Builder舊的或重命名的出口連接。如果您已經從其他地方複製了此代碼或某些資源,則需要更新它們以符合您的實際要求。

+0

非常感謝你的幫助。上面的代碼是可以的,我只是創建了一個新項目並複製了相同的代碼,它工作。所有文件中都沒有DatePickerView,奇怪的錯誤。 – Welbin