Skip to content

Instantly share code, notes, and snippets.

@spennyf
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save spennyf/162759685deeb3d777ba to your computer and use it in GitHub Desktop.

Select an option

Save spennyf/162759685deeb3d777ba to your computer and use it in GitHub Desktop.
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger buttonNumber = [self.mealdata mealsForDay:indexPath.row].count;
// NSLog(@"%d", buttonNumber);
switch (buttonNumber) {
case 2: {
TwoMealsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TwoMealsCell" forIndexPath:indexPath];
// configure the cell
cell.firstMealBtn.tag = indexPath.row;
cell.secondMealBtn.tag = indexPath.row + 10;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.dayLabel.text = [MealData stringForDeliDay:indexPath.row];
[cell.firstMealBtn setTitle:[self.mealdata mealsForDay:indexPath.row][0] forState:UIControlStateNormal];
[cell.secondMealBtn setTitle:[self.mealdata mealsForDay:indexPath.row][1] forState:UIControlStateNormal];
// [cell.firstMealBtn addTarget:self action:@selector(twoMealBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
// [cell.secondMealBtn addTarget:self action:@selector(twoMealBtnClicked:) forControlEvents:UIControlEventTouchUpInside];
tableView = UITableViewCellSeparatorStyleNone;
return cell;
}
}
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
return cell;
// UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
////
//// NSArray *meals=[self.mealdata mealsForDay:indexPath.section];
////
//// cell.textLabel.text=meals[indexPath.row];
//
// return cell;
}
#import <UIKit/UIKit.h>
@interface TwoMealsTableViewCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UILabel *dayLabel;
@property (strong, nonatomic) IBOutlet UIButton *firstMealBtn;
@property (strong, nonatomic) IBOutlet UIButton *secondMealBtn;
@property (nonatomic, strong) NSIndexPath *indexPath;
@end
#import "TwoMealsTableViewCell.h"
@implementation TwoMealsTableViewCell
@synthesize dayLabel, firstMealBtn, secondMealBtn, indexPath;
- (void)awakeFromNib {
[dayLabel setFrame:CGRectMake(20, 8, 200, 25)];
[firstMealBtn setFrame:CGRectMake(35, 40, 127.5, 35)];
[secondMealBtn setFrame:CGRectMake(165, 40, 127.5, 35)];
firstMealBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
secondMealBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
if ([currentUserAll[@"school"] isEqual:@"Union College (NY)"]) {
dayLabel.textColor = [UIColor blueColor];
[dayLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:18.0f]];
[firstMealBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
[secondMealBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
}
else if ([currentUserAll[@"school"] isEqual:@"University of Albany"]) {
dayLabel.textColor = [UIColor whiteColor];
[dayLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:18.0f]];
[firstMealBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[secondMealBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}
else if ([currentUserAll[@"school"] isEqual:@"Rensselaer Polytechnic Institute"]) {
dayLabel.textColor = [UIColor whiteColor];
[dayLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:18.0f]];
[firstMealBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[secondMealBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}
else if ([currentUserAll[@"school"] isEqual:@"The University of Vermont"]) {
dayLabel.textColor = [UIColor whiteColor];
[dayLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:18.0f]];
[firstMealBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[secondMealBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
}
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment