我是 iOS 开发新手。我试图在我的 ViewController 中显示 iOS 默认 CalendarView。现在我收到错误,请在下面找到我使用的代码。
viewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
{
UIDatePicker *datePicker;
UILabel *dateLabel;
}
@property (nonatomic, retain) IBOutlet UIDatePicker *datePicker;
@property (nonatomic, retain) IBOutlet UILabel *dateLabel;
-(IBAction) getSelection;
@property (nonatomic,copy) NSCalendar * calendar;
viewController.m
#import "ViewController.h"
@interface ViewController () //Error : Missing '@end'
@end //Error : Expected selector for objective c method
@implementation ViewController
@synthesize datePicker, dateLabel;
-(void)getSelection
{
NSLocale *usLocale = [[NSLocale alloc]
initWithLocaleIdentifier:@"en_US" ] ;
NSDate *pickerDate = [datePicker date];
NSString *selectionString = [[NSString alloc]
initWithFormat:@"%@",
[pickerDate descriptionWithLocale:usLocale]];
dateLabel.text = selectionString;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
最佳答案
对viewDidLoad调用getSelection方法
[self getSelection];
关于ios - 实现 CalendarView 应用程序 iOS SDK 7.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24078674/