开发者

Not getting the selected value from a PickerView

Im doing an Iphone app with a UIPickerView. The picker view has two columns that contains NSStrings. I have a button that generates a NSString containing the selected value of both columns in the PickerView and prints it in the log.

The problem is that it only prints the first two items in the picker view even if i change the selected value.

and i also get a warning, "Format not a string literal and no format arguments". and i have no idea even though i checked google for clues.

heres the code for the button action:

- (IBAction) sendButtonT开发者_如何学Pythonapped:(id)sender{
    NSString* theMessage = [NSString stringWithFormat:@"I'm %@ and feeling %@ about it.",
                            [activities objectAtIndex:[tweetPicker selectedRowInComponent:0]],
                            [feelings objectAtIndex:[tweetPicker selectedRowInComponent:1]]];
    NSLog(theMessage);
}


Log the selected row numbers to break down the problem:

NSLog(@"selectedRowInComponent0: %i", selectedRowInComponent:0);
NSLog(@"selectedRowInComponent1: %i", selectedRowInComponent:1);

Assuming that tweetPicker is an NSArray log it as well:

NSLog(@"tweetPicker: %@", tweetPicker);

It seems that NSLog wants a constant string for the first argument:

NSLog(@"%@", theMessage);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜