Субъективный Си / Говнокод #17190 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
// Somewhere in SWRevealViewController
// Load any defined front/rear controllers from the storyboard
// This method is intended to be overrided in case the default behavior will not meet your needs
//
- (void)loadStoryboardControllers 
{
    if ( self.storyboard && _rearViewController == nil )
    {
        //Try each segue separately so it doesn't break prematurely if either Rear or Right views are not used.
        @try
        {
            [self performSegueWithIdentifier:SWSegueRearIdentifier sender:nil];
        }
        @catch(NSException *exception) {}
        
        @try
        {
            [self performSegueWithIdentifier:SWSegueFrontIdentifier sender:nil];
        }
        @catch(NSException *exception) {}
        
        @try
        {
            [self performSegueWithIdentifier:SWSegueRightIdentifier sender:nil];
        }
        @catch(NSException *exception) {}
    }
}

stanislaw stanislaw, (Updated )

Комментарии (2, +2)

Субъективный Си / Говнокод #17094 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
@implementation SlideMenuNavigationBar

- (void)layoutSubviews
{
    [super layoutSubviews];

    for (UIView *aView in self.subviews) {
        
        // Correcting menu toggle button position
        if ([[aView.class description] isEqualToString:@"UIButton"] && aView.frame.origin.x < self.frame.size.width/2) {
            CGRect frame = aView.frame;
            frame.origin.x = 12; // 8 for correlation
            frame.origin.y = -1; // 1 for correlation
            aView.frame = frame;
        }
        
        if (aView.frame.origin.x > self.frame.size.width/2 && !isIPad && ![[aView.class description] isEqualToString:@"ColoredView"]) {
            CGRect frame = aView.frame;
            frame.origin.x = 260; // 8 for correlation
            frame.origin.y = -1;  // 1 for correlation
            aView.frame = frame;
        }
        
        // Correcting back button and right button positions
        if ([[aView.class description] isEqualToString:@"_UINavigationBarBackIndicatorView"]) {
            CGRect frame = aView.frame;
            frame.origin.y = [self.class navigationBarHeight] - kDefaultNavigationBarHeight + 5; // 5 for correlation
            aView.frame = frame;
        }
        if ([[aView.class description] isEqualToString:@"UINavigationButton"]) {
            CGRect frame = aView.frame;
            frame.origin.y = [self.class navigationBarHeight] - kDefaultNavigationBarHeight + 2; // 2 for correlation
            aView.frame = frame;
        }
        
        if ([aView isKindOfClass:[NavigationBarButton class]]) {
            CGRect frame = aView.frame;
            frame.origin.x = 278; // 8 for correlation
            frame.origin.y = 6;   // 1 for correlation
            aView.frame = frame;
        }
    }
}

@end

фиг знает что думали :D

l0gg3r l0gg3r, (Updated )

Комментарии (6, +6)

Субъективный Си / Говнокод #16907 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
id  obj =  [[FHSTwitterEngine sharedEngine] getHomeTimelineSinceID:nil count:100];

      if ( ![[[obj class] description] isEqualToString:@"NSError"] &&
          ![[[obj class] description] isEqualToString:@"NSURLError"])
 {
     if ([_categoriesDelegate respondsToSelector:@selector(didGetPostFromMyTW: forFeed:)])
         [_categoriesDelegate didGetPostFromMyTW:obj forFeed:@{@"id":feedId}];
 }
      else
          [SVProgressHUD dismiss];

оригинальное форматирование сохранено

heyyou heyyou, (Updated )

Комментарии (2, +2)

Субъективный Си / Говнокод #16823 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
float scaleFactor = param1/172;
        if (scaleFactor < -1)
        {
            scaleFactor = -1;
        }
        _releaseTheKraken.transform = CGAffineTransformMakeScale(-scaleFactor,-scaleFactor);
        float krakenPosition = param1/2.4571;
        
        if (param1<-172)
        {
            krakenPosition = -70 + 172 + param1;
            _activityIndicator.center = CGPointMake(25, param1+15);
        }
        _releaseTheKraken.center = CGPointMake(147.5, krakenPosition);
        if (param1<-100)
        {
            float param2 = (-param1 - 100)/7.5;
            int param3 = floor(param2);
            if (param3<10)
            {...

soprof soprof, (Updated )

Комментарии (11, +11)

Субъективный Си / Говнокод #16789 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
- (void)viewDidLoad
{
    [super viewDidLoad];
    
    UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Save", nil) style:UIBarButtonItemStylePlain target:self action:@selector(save:)];
    
    // ...

    self.navigationItem.rightBarButtonItems = @[saveButton, someOtherButton];

    self.saveBarButtonItem = saveButton;
}

- (void)someMethod
{
    [self.navigationItem.rightBarButtonItems enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop){
        UIBarButtonItem *barItem = (UIBarButtonItem *)obj;
        if ([barItem.title isEqualToString:NSLocalizedString(@"Save", nil)]) {
            barItem.enabled = NO;
        }
    }];
}

Задача: включать/выключать кнопку по определенному событию.

gumbert gumbert, (Updated )

Комментарии (1, +1)

Субъективный Си / Говнокод #16788 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [TMSpinner hide];
    if (self.registrationModel && !self.loggedIn && [[self.webView.request.URL absoluteString] length]) {
        [self autologinTheWebView];
    }
}

#pragma mark - Black magic

- (void)autologinTheWebView {
    [self.webView stringByEvaluatingJavaScriptFromString:[self javascriptToInject]];
    [self.webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"autologin('%@', '%@');", self.registrationModel.email, self.registrationModel.password]];
    self.loggedIn = YES;
}

- (NSString *)javascriptToInject {
    return @"autologin = function(email, password) {"
           @"  var emailField = document.getElementById('user_email');"
           @"  var passwordField = document.getElementById('user_password');"
           @"  var submitButton = document.querySelector('input.btn.btn-default.btn-success');"
           @"  emailField.value = email;"
           @"  passwordField.value = password;"
           @"  submitButton.click();"
           @"};";
}

js в obj-c. кому то после меня это поддерживать :)

Drenwtc Drenwtc, (Updated )

Комментарии (5, +5)

Субъективный Си / Говнокод #16751 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
- (void)config
{
    self.contentView.backgroundColor = [UIColor NaviCellBgColor];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    UIImageView *theDisclosureView = _disclosureView;
    UILabel *theLabel = _titleLabel;
    if (self.isHighlighted)
    {
        theLabel.shadowColor = [UIColor TextShadowColor];
        theLabel.shadowOffset = CGSizeMake(0.0f, -0.5f);
        self.contentView.backgroundColor = [UIColor NaviCellBgHighlightColor];
        theLabel.textColor = [UIColor GreenTextColor];
        self.contentView.backgroundColor = [UIColor NaviCellBgHighlightColor];
        theDisclosureView.image = [UIImage imageNamed:@"Button_Disclosure_touch"];
    }
    else
    {
        theLabel.shadowColor = [UIColor TextShadowColor];
        theLabel.shadowOffset = CGSizeMake(0.0f, -0.5f);
        self.contentView.backgroundColor = [UIColor NaviCellBgHighlightColor];
        theLabel.textColor = [UIColor GreenTextColor];
        self.contentView.backgroundColor = [UIColor NaviCellBgColor];
        theDisclosureView.image = [UIImage imageNamed:@"Button_Disclosure"];
    }

    UIActivityIndicatorView *theIndicator = _loadingIndicator;
    if (_loading)
        [theIndicator startAnimating];
    else
        [theIndicator stopAnimating];
    
    UILabel *theTitleLabel = _titleLabel;
    theTitleLabel.textColor = [UIColor GreenTextColor];
}

Код вид культурного европэйця. Справжний европейский кодстайл.

Psionic Psionic, (Updated )

Комментарии (0)