Last active
August 29, 2015 14:23
-
-
Save jenhausu/2ccb72aace478446857b to your computer and use it in GitHub Desktop.
UITableView
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| else if (indexPath.section == 1) { | |
| ZeroTableViewCell *cell2 = [tableView dequeueReusableCellWithIdentifier:@"Cell2" forIndexPath:indexPath]; | |
| cell2.text.text = setting[indexPath.section][indexPath.row]; | |
| cell2.detailText.text = zero[[userPreferences integerForKey:@"計時器歸零"]]; | |
| cell2.detailTextLabel.font = [UIFont systemFontOfSize:10]; | |
| cell2.accessoryType = UITableViewCellAccessoryDisclosureIndicator; | |
| return cell2; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | |
| { | |
| UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; | |
| cell.textLabel.text = setting[indexPath.section][indexPath.row]; | |
| cell.detailTextLabel.text = @" "; | |
| if (indexPath.section == 0) { | |
| if (indexPath.row == 0) { | |
| NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; | |
| [formatter setDateFormat:@"HH:mm"]; | |
| cell.detailTextLabel.text = [formatter stringFromDate:[[[IntelligentNotification alloc] init] decideShouldGoToBedTime]]; | |
| cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; | |
| cell.accessoryView = nil; | |
| cell.selectionStyle = UITableViewCellSelectionStyleDefault; | |
| } else if (indexPath.row == 1) { | |
| UISwitch *switchControl = [[UISwitch alloc] initWithFrame:CGRectMake(1.0, 1.0, 20.0, 30.0)]; | |
| cell.accessoryView = switchControl; | |
| switchControl.on = [userPreferences boolForKey:@"重複發出睡前通知"]; | |
| [switchControl addTarget:self action:@selector(switchChanged1:) forControlEvents:UIControlEventValueChanged]; | |
| cell.selectionStyle = UITableViewCellSelectionStyleNone; | |
| } | |
| } else if (indexPath.section == 1) { | |
| ZeroTableViewCell *cell2 = [tableView dequeueReusableCellWithIdentifier:@"Cell2" forIndexPath:indexPath]; | |
| cell2.text.text = setting[indexPath.section][indexPath.row]; | |
| cell2.detailText.text = zero[[userPreferences integerForKey:@"計時器歸零"]]; | |
| cell2.detailTextLabel.font = [UIFont systemFontOfSize:10]; | |
| cell2.accessoryType = UITableViewCellAccessoryDisclosureIndicator; | |
| return cell2; | |
| } else if (indexPath.section == (setting.count - 1)) { | |
| cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; | |
| } | |
| return cell; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | |
| { | |
| if (indexPath.section != 1) { | |
| UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; | |
| cell.textLabel.text = setting[indexPath.section][indexPath.row]; | |
| cell.detailTextLabel.text = @" "; | |
| if (indexPath.section == 0) { | |
| if (indexPath.row == 0) { | |
| NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; | |
| [formatter setDateFormat:@"HH:mm"]; | |
| cell.detailTextLabel.text = [formatter stringFromDate:[[[IntelligentNotification alloc] init] decideShouldGoToBedTime]]; | |
| cell.detailTextLabel.font = [UIFont systemFontOfSize:15]; | |
| cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; | |
| cell.accessoryView = nil; | |
| cell.selectionStyle = UITableViewCellSelectionStyleDefault; | |
| } else if (indexPath.row == 1) { | |
| UISwitch *switchControl = [[UISwitch alloc] initWithFrame:CGRectMake(1.0, 1.0, 20.0, 30.0)]; | |
| cell.accessoryView = switchControl; | |
| switchControl.on = [userPreferences boolForKey:@"重複發出睡前通知"]; | |
| [switchControl addTarget:self action:@selector(switchChanged1:) forControlEvents:UIControlEventValueChanged]; | |
| cell.selectionStyle = UITableViewCellSelectionStyleNone; | |
| } | |
| } else if (indexPath.section == (setting.count - 1)) { | |
| cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; | |
| } | |
| return cell; | |
| } else { | |
| ZeroTableViewCell *cell2 = [tableView dequeueReusableCellWithIdentifier:@"Cell2" forIndexPath:indexPath]; | |
| cell2.text.text = setting[indexPath.section][indexPath.row]; | |
| cell2.detailText.text = zero[[userPreferences integerForKey:@"計時器歸零"]]; | |
| cell2.detailText.font = [UIFont systemFontOfSize:15]; | |
| cell2.accessoryType = UITableViewCellAccessoryDisclosureIndicator; | |
| return cell2; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment