iphone - UIPickerView only displays one component; should display two -


have uipicker should display 2 components (columns in picker view), displaying one.

can't find error; builds correctly. second component empty; no data displayed.

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 view if doesn't have superview.     [super didreceivememorywarning];      // release cached data, images, etc aren't in use. }  #pragma mark - view lifecycle  // implement viewdidload additional setup after loading view, typically    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 

you not returning value in pickerview:titleforrow:incomponent: method second component.

if (component == 0) {     return [activities_ objectatindex:row]; } else {     [feelings_ objectatindex:row]; } 

you should

return [feelings_ objectatindex:row]; 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -