Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.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
Objective c UIPickerView未申报?_Objective C_Xcode_Datasource_Uipickerview - Fatal编程技术网

Objective c UIPickerView未申报?

Objective c UIPickerView未申报?,objective-c,xcode,datasource,uipickerview,Objective C,Xcode,Datasource,Uipickerview,我遇到了一个小问题,我在下面代码的第1行遇到了一个错误,说“'UIPickerView'未声明。我从我的书中抄了出来,我不确定出了什么问题? 我能得到一些帮助吗?非常感谢,谢谢:) 这是整个.m文件代码 #import "InstatwitViewController.h" @implementation InstatwitViewController - (void)viewDidLoad { [super viewDidLoad]; activities = [[NSArray al

我遇到了一个小问题,我在下面代码的第1行遇到了一个错误,说“'UIPickerView'未声明。我从我的书中抄了出来,我不确定出了什么问题? 我能得到一些帮助吗?非常感谢,谢谢:)

这是整个.m文件代码

#import "InstatwitViewController.h"

@implementation InstatwitViewController

- (void)viewDidLoad {

[super viewDidLoad];

activities = [[NSArray alloc] initWithObjects:@"sleeping",
@"eating", @"working", @"thinking", @"crying", @"begging",
@"leaving", @"shopping", @"hello worlding", nil];

feelings = [[NSArray alloc] initWithObjects:@"awesome",
@"sad", @"happy", @"ambivalent", @"nauseous", @"psyched",
@"confused", @"hopeful", @"anxious", nil];
}


- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)
pickerView {
return 2;
}
- (NSInteger)PickerView:(UIPickerView *)pickerViewnumberOfRowsInComponent :      (NSInteger)component {
if (component == 0) {
    return [activities count];

}
else {
    return [feelings count];
}
}


- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
    switch (component) {
        case 0:

            return [activities objectAtIndex:row];

        case 1:
            return [feelings objectAtIndex:row];

    }
    return nil;

}
}

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

@end
你把它复制到哪里了?它应该在你正在实现的类的
.m
文件的
@implementation
..
@end
部分。它应该而不是
@接口
..
@end
部分,通常在
.h
文件中,或者其他地方,即
@imple之外校正
@end
部分

请显示更多的代码

编辑 这:

-(NSString*)pickerView:…
之前缺少结束符
}
。换句话说,将其更改为:

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

}

- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

}

- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {