- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = nil;
if (indexPath.row == self.titles.count - 1)
{
cell = [tableView dequeueReusableCellWithIdentifier:@"settingButtonCell" forIndexPath:indexPath];
SWSettingButtonCell *scell = (SWSettingButtonCell *) cell;
[scell.settingButton setTitleForAllStates:self.titles[indexPath.row]];
[scell.settingButton bk_removeEventHandlersForControlEvents:UIControlEventTouchUpInside];
scell.settingIcon.visible = YES;
@weakify(self);
[scell.settingButton bk_addEventHandler:^(id sender) {
[UIAlertView bk_showAlertViewWithTitle:@"Logout"
message:@"Do you want to logout?"
cancelButtonTitle:@"NO"
otherButtonTitles:@[@"YES"]
handler:^(UIAlertView *alertView, NSInteger buttonIndex) {
@strongify(self);
if (buttonIndex != 0)
{
[[SWCore instance] logout];
// fix
[SVProgressHUD show];
// end fix
}
}];
} forControlEvents:UIControlEventTouchUpInside];
}
else if (indexPath.row == self.titles.count - 2)
{
cell = [tableView dequeueReusableCellWithIdentifier:@"settingButtonCell" forIndexPath:indexPath];
SWSettingButtonCell *scell = (SWSettingButtonCell *) cell;
[scell.settingButton setTitleForAllStates:self.titles[indexPath.row]];
[scell.settingButton bk_removeEventHandlersForControlEvents:UIControlEventTouchUpInside];
scell.settingIcon.visible = NO;
@weakify(self);
[scell.settingButton bk_addEventHandler:^(id sender) {
@strongify(self);
[self performSegueWithIdentifier:@"pushSettingsSegue" sender:nil];
} forControlEvents:UIControlEventTouchUpInside];
}
else
{
cell = [tableView dequeueReusableCellWithIdentifier:@"settingCell" forIndexPath:indexPath];
SWSettingCell *scell = (SWSettingCell *) cell;
scell.settingLabel.text = self.titles[indexPath.row];
[scell.settingIcon setImage:self.icons[indexPath.row]];
switch (indexPath.row)
{
case 0:
{
scell.settingSwitch.on = [[SWCore account].settings[[NSString stringWithFormat:SETTINGS_PROFILE_VISIBILITY]] isEqualToString:SETTING_PUBLIC];
scell.settingIcon.image = scell.settingSwitch.isOn ? [UIImage imageNamed:@"settings_profile_icon_on"] : [UIImage imageNamed:@"settings_profile_icon_off"];
}
break;
case 1:
{
scell.settingSwitch.on = [[SWCore account].settings[[NSString stringWithFormat:SETTINGS_EVENTS_VISIBILITY]] isEqualToString:SETTING_PUBLIC];
scell.settingIcon.image = scell.settingSwitch.isOn ? [UIImage imageNamed:@"settings_events_button_on"] : [UIImage imageNamed:@"settings_events_button_off"];
}
break;
case 2:
{
scell.settingSwitch.on = [[SWCore account].settings[[NSString stringWithFormat:SETTINGS_PHONE_VISIBILITY]] isEqualToString:SETTING_PUBLIC];
scell.settingIcon.image = scell.settingSwitch.isOn ? [UIImage imageNamed:@"settings_phone_button_on"] : [UIImage imageNamed:@"settings_phone_button_off"];
}
break;
case 3:
{
scell.settingSwitch.on = [[SWCore account].settings[[NSString stringWithFormat:SETTINGS_PHOTOS_VISIBILITY]] isEqualToString:SETTING_PUBLIC];
scell.settingIcon.image = scell.settingSwitch.isOn ? [UIImage imageNamed:@"settings_photos_button_on"] : [UIImage imageNamed:@"settings_photos_button_off"];
}
break;
default:
break;
}
scell.settingSwitch.tag = indexPath.row;
[scell.settingSwitch bk_removeEventHandlersForControlEvents:UIControlEventValueChanged];
Один из самых классных методов cellForRowAtIndexPath что я когда-либо видел
Gerchicov-bp 07.04.2015 10:14 # +1
krypt 13.04.2015 03:32 # 0
Пфффф..... А я опять со своей волшебной ссылкой: http://pastebin.com/UaTdN6K2
Осторожно, после просмотра ссылки ваша жизнь больше не будет прежней. И да, это из проекта, который я поддерживал.
3.14159265 14.04.2015 14:12 # −13
guest8 27.05.2019 22:25 # −999
3.14159265 14.04.2015 14:13 # −6
Stertor 14.04.2015 14:50 # −1
guest 14.04.2015 14:55 # +1
guest 14.04.2015 15:23 # 0
http://rghost.ru/8vSClWSj2
guest8 27.05.2019 22:26 # −999
da_vi_ohueli 15.04.2015 00:47 # 0
3_14_nu_ti_i_mudak 15.04.2015 00:48 # 0