【发布时间】:2014-04-23 02:26:19
【问题描述】:
我想要做的是让两个 UISegmentedControl 框将 itemCondition 和 itemLocation 对象属性设置为各自的值,具体取决于按下的按钮。
然后,该值将作为参数发送到 Parse 云代码函数,如 submitButton 函数所示。我知道以 minPrice 和 maxPrice 为例,这些是用户提供的值,因此您可以将 self.minPrice.text 作为参数发送。
将 UISegmentedControl 设置为 self.itemCondition 并将其作为参数发送似乎不起作用。由于分段按钮是设置值的对象,而不是用户在文本框中明确键入内容,我认为它的完成方式不同,我只是不确定如何。
这是来自我的 criteriaViewController 的代码,用于处理提到的所有内容。
- (IBAction)conditionToggle:(id)sender{
if(Segment.selectedSegmentIndex == 0){
self.itemCondition == 'new';
}
else if(Segment.selectedSegmentIndex == 1){
self.itemCondition == 'any';
}
}
- (IBAction)itemLocationToggle:(id)sender {
if(Segment.selectedSegmentIndex == 0){
self.itemLocation == 'US';
}
else if(Segment.selectedSegmentIndex == 1){
self.itemLocation == 'WorldWide';
}
}
- (IBAction)submitButton:(id)sender
{
if (self.itemSearch.text.length > 0) {
//add all the info to users respective category object
//perform search with criteria just submitted
[PFCloud callFunctionInBackground:@"eBayCriteriaSearch"
withParameters:@{@"item": self.itemSearch.text,
@"minPrice": self.minPrice.text,
@"maxPrice": self.maxPrice.text,
@"itemCondition": self.itemCondition,
@"itemLocation": self.itemLocation,}
block:^(NSString *result, NSError *error) {
if (!error) {
NSLog(@"The result is '%@'", result);
if ([result intValue] == 1) {
[self performSegueWithIdentifier:@"ShowMatchCenterSegue" sender:self];
} else {
[self performSegueWithIdentifier:@"ShowCriteriaSegue" sender:self];
}
}
}];
}
}
【问题讨论】:
标签: ios objective-c uisegmentedcontrol