ios - 实现 CalendarView 应用程序 iOS SDK 7.1

标签 ios objective-c

我是 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/

相关文章:

ios - 如何从不同的 View Controller 访问模型?

ios - swift : Cast wrapped value

ios - 空气原生扩展 FDT

ios - Xcode 7.2 更新后,可执行文件使用无效权利进行签名

iphone - 美国的NSLocale?

objective-c - Realm 抛出空单元测试异常

ios - 在 Xcode 6 中手动创建空应用程序后的全屏问题

ios - tokbox中 session 和 token 的有效性是什么?

ios - CoreLocation 在一定时间后停止在后台工作

ios - 嵌套 UIAlertView