zoukankan      html  css  js  c++  java
  • iOS 开发技巧总结

    1. 添加定时器的常用代码

     1 - (void)delayEnableTabButton
     2 {
     3     self.tabChannelButton.enabled = NO;
     4     [self appendTimer];
     5 }
     6 
     7 - (void)appendTimer
     8 {
     9     if (_resumeTimer == nil)
    10     {
    11         _resumeTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(enableTabChannelButton) userInfo:nil repeats:NO];
    12     }
    13 }
    14 
    15 - (void)enableTabChannelButton
    16 {
    17     self.tabChannelButton.enabled = YES;
    18     [self removeTimer];
    19 }
    20 
    21 - (void)removeTimer
    22 {
    23     if (_resumeTimer != nil)
    24     {
    25         [_resumeTimer invalidate];
    26         _resumeTimer = nil;
    27     }
    28 }
    29 
    30 
    31 - (void)dealloc
    32 {
    33     [self removeTimer];
    34 }
    View Code

    2. 对于用户多次点击的事件,为防止重复调用而覆盖操作,可以延迟执行.如:

     1     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
     2         if (!_processFlowView.hidden) {
     3             return ;
     4         }
     5         _processFlowView.hidden = NO;
     6         _processFlowViewLeft.constant = _windNameStart;
     7         [self layoutIfNeeded];
     8         [UIView animateWithDuration:0.5 animations:^{
     9             _processFlowViewLeft.constant = _windNameEnd;
    10             [self layoutIfNeeded];
    11         } completion:^(BOOL finished) {
    12             _processFlowView.hidden = YES;
    13         }];
    14     });
    View Code

    3. 写  UI 的代码时, 能复制粘贴的尽量复制粘贴, 快速开发...可以使用 headerTitleLabel1, headerTitleLabel2, middleTitleLabel1来代替复杂的命名规则.

    4. 对于 UI 比较复杂的界面, 可以定义多个大容器, 对于修改 UI 的话, 比较方便.

    5. 写  UI 的时候, 可以打开 xcode 的分屏功能, 左右两个界面对照编辑

    6. 对于数据的特殊显示, 如进度为100%时, 仍显示99%, 可以在代码的最底层处理, 也就是 UI层, 在设置 UIlabel 的 text 时做处理, 其他地方就不用重复处理了, 以免出问题了不好查找.

  • 相关阅读:
    Codeforces Round 546 (Div. 2)
    Codeforces Round 545 (Div. 2)
    Codeforces Round 544(Div. 3)
    牛客小白月赛12
    Codeforces Round 261(Div. 2)
    Codeforces Round 260(Div. 2)
    Codeforces Round 259(Div. 2)
    Codeforces Round 258(Div. 2)
    Codeforces Round 257 (Div. 2)
    《A First Course in Probability》-chaper5-连续型随机变量-随机变量函数的分布
  • 原文地址:https://www.cnblogs.com/lz465350/p/5477276.html
Copyright © 2011-2022 走看看