-
−352
- 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 что я когда-либо видел
shadeapps,
06 Апреля 2015
-
−403
- 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
if (indexPath.row == 0) {
if (![centerViewController isKindOfClass:[T7DUserInfoViewController class]]) {
T7DUserInfoViewController *userViewController = [[T7DUserInfoViewController alloc] init];
[navigationController popViewControllerAnimated:NO];
[navigationController pushViewController:userViewController animated:NO];
}
}
if (indexPath.row == 1) {
if (![centerViewController isKindOfClass:[T7DMapViewController class]]) {
T7DMapViewController *mapViewController = [[T7DMapViewController alloc] init];
[navigationController popViewControllerAnimated:NO];
[navigationController pushViewController:mapViewController animated:NO];
}
}
if (indexPath.row == 2) {
if (![centerViewController isKindOfClass:[T7DOrderListViewController class]]) {
T7DOrderListViewController *orderListViewController = [[T7DOrderListViewController alloc] init];
[navigationController popViewControllerAnimated:NO];
[navigationController pushViewController:orderListViewController animated:NO];
}
}
if (indexPath.row == 3) {
if (![centerViewController isKindOfClass:[T7DCurrentOrderViewController class]]) {
T7DCurrentOrderViewController *orderViewController = [[T7DCurrentOrderViewController alloc] init];
[orderViewController setOrderType:T7DOrderTypeCurrent];
[orderViewController setOrder:[T7DOrder currentOrder]];
[navigationController popViewControllerAnimated:NO];
[navigationController pushViewController:orderViewController animated:NO];
}
}
if (indexPath.row == 4) {
if (![centerViewController isKindOfClass:[T7DMessagesViewController class]]) {
T7DMessagesViewController *messagesViewConroller = [[T7DMessagesViewController alloc] init];
[navigationController popViewControllerAnimated:NO];
[navigationController pushViewController:messagesViewConroller animated:NO];
}
}
if (indexPath.row == 5) {
[self logout];
return;
}
Мудаки.
pr0gl,
31 Марта 2015
-
−406
- 1
- 2
- 3
- 4
- 5
- 6
- 7
Код конца 2014 года
CGSize iOSDeviceScreenSize = [[UIScreen mainScreen] bounds].size;
if (iOSDeviceScreenSize.height == 480)
isRetina = true;
else
isRetina = false;5
Headless,
23 Марта 2015
-
−407
- 1
- 2
- 3
- 4
- 5
- 6
- 7
#define RETURN_CREATED_SGINGLETON_MUTABLE_ARRAY \
static NSMutableArray* _singletonArray = nil; \
static dispatch_once_t onceToken; \
dispatch_once(&onceToken, ^{ \
_singletonArray = [[NSMutableArray alloc] init]; \
}); \
return _singletonArray;
Используется массив для хранения заданий. Эдакий самописный NSOperationQueue.
ProFFeSSoR,
23 Марта 2015
-
−397
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
[array_static removeAllObjects];
[array_static addObject:@"Files"];
[array addObjectsFromArray:[filemanager contentsOfDirectoryAtPath:DOCUMENTS error:nil]];
for (int l=0; l<array.count; l++) {
for (int j=0; j<array.count; j++) {
for (int i=0; i<array.count; i++) {
if ([[array objectAtIndex:i] rangeOfString:@"."].location != NSNotFound) {
[array removeObjectAtIndex:i];
}
}
}
}
for (int i = 0; i<array.count; i++) {
if (![array_static containsObject:[array objectAtIndex:i]]) {
[array_static addObject:[array objectAtIndex:i]];
}
}
Дали задание добавить фичу в один старый проект. Открыл проект, сижу и наслаждаюсь видом 8)
OUrsus,
16 Марта 2015
-
−387
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
@implementation UINavigationController (LastControllerBar)
- (UIStatusBarStyle)preferredStatusBarStyle {
if (self.viewControllers.count)
return [[self.viewControllers lastObject] preferredStatusBarStyle];
return UIStatusBarStyleDefault;
}
@end
Категория из VKSDK: https://github.com/VKCOM/vk-ios-sdk/blob/master/sdk/Source/Views/VKAuthorizeController.m
Долго разбирался, почему у меня буквы в статусбаре стали чёрными.
watupiwa,
27 Февраля 2015
-
−388
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- (void) setLevel:(NSInteger)level {
if (level > (long)[_ranksDictionary count] - 1) level = (long)[_ranksDictionary count] - 1;
if (level < 0) level = 0;
_level = level;
self.currentRank = [_ranksDictionary objectForKey:[NSNumber numberWithInteger:_level]];
if (rankDataItem.integerValue != -_level)
rankDataItem.integerValue = _level;
}
Я совсем хуевый?
ExT,
28 Января 2015
-
−396
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
BOOL = omg;
if (omg == YES)
{
[self go];
}
else
{
if (omg == YES)
{
omg = YES;
[self go];
}
}
МОИ ГЛАЗАААА
ShuZik,
23 Января 2015
-
−404
- 1
UIImageView *footerWhite1PxLineThatOnlyAndersWillNotice = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"sidebar_line_white"]];
ох уж этот Андерс!
besprincypniycentner,
23 Декабря 2014
-
−402
- 1
NSParameterAssert(![method isEqualToString:@"GET"] && ![method isEqualToString:@"HEAD"]);
код из afnetworking - американцы поймут что такое GET HEAD)))))))))))))
kyzmitch,
15 Декабря 2014