这是我的代码:
-(void)btnSelectItem:(id)sender{
NSString *userId =[[NSUserDefaults standardUserDefaults] valueForKey:USER_ID_KEY];
[sender setBackgroundImage:[UIImage imageNamed:@"radio_selected"] forState:UIControlStateNormal];
int i = (int)[sender tag];
//[CollectionViewSize performBatchUpdates:^{ [CollectionViewSize reloadItemsAtIndexPaths:@[[NSIndexPath indexPathForRow:i inSection:0]]]; } completion:nil];
// [CollectionViewSize reloadItemsAtIndexPaths:@[[NSIndexPath indexPathForRow:i section:0]]];
strMenuID = [NSString stringWithFormat:@"%@",[[arayResponce objectAtIndex:i]valueForKey:@"menu_id"]];
lblItemCount.text = [NSString stringWithFormat:@"%@",[[arayResponce objectAtIndex:i]valueForKey:@"price"]];
[adCartParam removeAllObjects];
adCartParam = [NSMutableDictionary dictionary];
[adCartParam setObject:[NSNumber numberWithInt:kresto_id] forKey:@"resto_id"];
[adCartParam setObject:strMenuID forKey:@"menu_id"];
[adCartParam setObject:userId forKey:@"cust_id"];
[adCartParam setObject:[AppDelegate getDelegate].subCategoryID forKey:@"cat_id"];
NSString *price = [CommonClass stringByReplacing:lblItemCount.text and:@"$" withString:@""];
///[lblItemCount.text stringByReplacingOccurrencesOfString:@"$"
// withString:@""];
[adCartParam setObject:price forKey:@"price"];
[adCartParam setObject:@1 forKey:@"qty"];
[adCartParam setObject:[[arayResponce objectAtIndex:i]valueForKey:@"size_id"] forKey:@"size_id"];
}
答案 0 :(得分:0)
//if you need the highlight
[button setHighlighted:YES];
[button sendActionsForControlEvents:UIControlEventTouchUpInside];
答案 1 :(得分:0)
[self btnSelectItem:yourButton];
答案 2 :(得分:0)
首先您使用-(void)btnSelectItem:(id)sender
更改-(void)btnSelectItem:(UIButton*)sender
然后从任何方法调用它。与[self btnSelectItem:yourButtonOutlet]