Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 不完全执行_Ios_Xcode - Fatal编程技术网

Ios 不完全执行

Ios 不完全执行,ios,xcode,Ios,Xcode,我在我的实现页面上收到了一个不完整的实现警告,我已将其注释掉: #import "BIDDatePickerViewController.h" @implementation BIDDatePickerViewController // Incomplete implementation @synthesize datePicker; - (IBAction)buttonPressed:(id)sender { NSDate *selected = [datePicker da

我在我的实现页面上收到了一个不完整的实现警告,我已将其注释掉:

#import "BIDDatePickerViewController.h"

@implementation BIDDatePickerViewController   // Incomplete implementation

@synthesize datePicker;

- (IBAction)buttonPressed:(id)sender
{
    NSDate *selected = [datePicker date];
    NSString *message = [[NSString alloc] initWithFormat:@"The date and time you selected is:%@", selected];
    UIAlertView *alert = [[UIAlertView alloc]
                          initWithTitle:@"Date and Time Selected" 
                          message:message 
                          delegate:nil 
                          cancelButtonTitle:@"Yes I did" 
                          otherButtonTitles:nil];
    [alert show];
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    NSDate *now = [NSDate date];
    [datePicker setDate:now animated:NO];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
    self.datePicker = nil;

}
@end
此外,消息的自定义部分(显示所选日期和时间)显示不正确。为什么?

以下是接口文件:

#import <UIKit/UIKit.h>

@interface BIDDatePickerViewController : UIViewController

@property (strong, nonatomic) IBOutlet UIDatePicker *datePicker;

-(IBAction)buttonPressed;

@end
#导入
@接口BIDDatePickerViewController:UIViewController
@属性(强,非原子)IBUIDatePicker*datePicker;
-(IBAction)按钮按下;
@结束

在.h文件中,您按下了
-(iAction)按钮
并且在.m文件中,您已经按下了
-(iAction)按钮:(id)sender
。您应该按下
-(iAction)按钮
在.m文件中

您收到警告的原因是您实现了方法
-(iAction)buttonPressed:(id)sender
,而您定义了方法
-(iAction)buttonPressed。注意界面上没有参数。

谢谢,这很有效。无法找出NSDate*selected未传递到UIAlertView消息的原因。消息的其余部分正在显示,但当涉及到*选定时。它在消息中显示为(null)。知道为什么吗?很可能是因为您忘记在interface builder中连接datePicker属性。您可以通过设置断点并查看它是否为有效对象来进行双重检查。