0
2つのコンポーネント(ピッカービュー内の列)を表示するUIPickerがありますが、1つしか表示されていません。UIPickerViewは1つのコンポーネントのみを表示します。 2つ表示する必要があります。
エラーは見つかりませんでした。それは正しく構築されます。 2番目のコンポーネントは空です。データは表示されません。
InstaEmailViewController.h
#import <UIKit/UIKit.h>
@interface InstaEmailViewController : UIViewController
<UIPickerViewDataSource, UIPickerViewDelegate> {
NSArray* activities_ ;
NSArray* feelings_ ;
}
InstaEmailViewController.m
#import "InstaEmailViewController.h"
@implementation InstaEmailViewController
- (void)dealloc
{
[activities_ release];
[feelings_ 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.
}
#pragma mark - View lifecycle
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
activities_ = [[NSArray alloc] initWithObjects:@"sleeping", @"working", @"thinking", @"crying", @"begging", @"leaving", @"shopping", @"hello worlding", nil];
feelings_ = [[NSArray alloc] initWithObjects: @"awesome", @"sad", @"ambivalent", @"nauseous",@"psyched", @"confused", @"hopeful", @"anxious", nil];
[super viewDidLoad];
}
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
if (component == 0) {
return [activities_ objectAtIndex:row];
} else {
[feelings_ objectAtIndex:row];
}
return nil;
}
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView {
return 2;
}
- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent: (NSInteger)component {
if (component ==0) {
return [activities_ count];
} else {
return [feelings_ count];
}
}
@end