日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > 綜合技術 > iOS開發的一些奇巧淫技

iOS開發的一些奇巧淫技

來源:程序員人生   發布時間:2016-11-11 08:56:39 閱讀次數:2741次

TableView不顯示沒內容的Cell怎樣辦?

類似這類,我不想讓下面那些空的顯示.

01.png

很簡單.

1
self.tableView.tableFooterView = [[UIView alloc] init];

試過的都說好.

加完這句以后就變成了這樣.

02.png

自定義了leftBarbuttonItem左滑返回手勢失效了怎樣辦?

1
2
3
4
5
6
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
                                         initWithImage:img
                                         style:UIBarButtonItemStylePlain
                                         target:self
                                         action:@selector(onBack:)];
self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;

ScrollView稀里糊涂不能在viewController劃到頂怎樣辦?

1
self.automaticallyAdjustsScrollViewInsets = NO;

鍵盤事件寫的好煩躁,都想摔鍵盤了,怎樣辦?

1.買個結實的鍵盤.

2.使用IQKeyboardManager(github上可搜索),用完以后腰也不疼了,腿也不酸了.

為何我的app總是不流暢,到底哪里出了問題?

如圖

03.gif

這個神器叫做:KMCGeigerCounter,快去github搬運吧.

怎樣在不新建1個Cell的情況下調劑separaLine的位置?

1
_myTableView.separatorInset = UIEdgeInsetsMake(0, 100, 0, 0);

怎樣點擊self.view就讓鍵盤收起,需要添加1個tapGestures么?

1
2
3
4
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
   [self.view endEditing:YES];
}

怎樣給每一個ViewController設定默許的背景圖片?

使用基類啊,少年。

想在代碼里改在xib里添加的layoutAttributes,但是怎樣用代碼找啊?

像拉button1樣的拉你的束縛.nslayoutattribute也是可以拉線的.

怎樣像safari1樣滑動的時候隱藏navigationbar?

1
navigationController.hidesBarsOnSwipe = Yes

導航條返回鍵帶的title太討厭了,怎樣讓它消失!

1
2
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, ⑹0)
                                                     forBarMetrics:UIBarMetricsDefault];

CoreData用起來好煩,語法又臭又長,怎樣辦?

MagicRecord

CollectionView 怎樣實現tableview那種懸停的header?

CSStickyHeaderFlowLayou

能不能只用1個pan手勢來代替UISwipegesture的各個方向?

1
2
3
4
5
6
7
8
9
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
- (void)pan:(UIPanGestureRecognizer *)sender
{
typedef NS_ENUM(NSUInteger, UIPanGestureRecognizerDirection) {
    UIPanGestureRecognizerDirectionUndefined,
    UIPanGestureRecognizerDirectionUp,
    UIPanGestureRecognizerDirectionDown,
    UIPanGestureRecognizerDirectionLeft,
    UIPanGestureRecognizerDirectionRight
};
static UIPanGestureRecognizerDirection direction = UIPanGestureRecognizerDirectionUndefined;
switch (sender.state) {
    case UIGestureRecognizerStateBegan: {
        if (direction == UIPanGestureRecognizerDirectionUndefined) {
            CGPoint velocity = [sender velocityInView:recognizer.view];
            BOOL isVerticalGesture = fabs(velocity.y) > fabs(velocity.x);
            if (isVerticalGesture) {
                if (velocity.y > 0) {
                    direction = UIPanGestureRecognizerDirectionDown;
                } else {
                    direction = UIPanGestureRecognizerDirectionUp;
                }
            }
            else {
                if (velocity.x > 0) {
                    direction = UIPanGestureRecognizerDirectionRight;
                } else {
                    direction = UIPanGestureRecognizerDirectionLeft;
                }
            }
        }
        break;
    }
    case UIGestureRecognizerStateChanged: {
        switch (direction) {
            case UIPanGestureRecognizerDirectionUp: {
                [self handleUpwardsGesture:sender];
                break;
            }
            case UIPanGestureRecognizerDirectionDown: {
                [self handleDownwardsGesture:sender];
                break;
            }
            case UIPanGestureRecognizerDirectionLeft: {
                [self handleLeftGesture:sender];
                break;
            }
            case UIPanGestureRecognizerDirectionRight: {
                [self handleRightGesture:sender];
                break;
            }
            default: {
                break;
            }
        }
        break;
    }
    case UIGestureRecognizerStateEnded: {
        direction = UIPanGestureRecognizerDirectionUndefined;   
        break;
    }
    default:
        break;
}
}

拉伸圖片的時候怎樣才能讓圖片不變形?
1.UIImage *image = [[UIImage imageNamed:@"xxx"] stretchableImageWithLeftCapWidth:10 topCapHeight:10];

2.

05.gif


怎樣播放GIF的時候這么卡,有無好點的庫?

FlipBoard出品的太合適你了:https://github.com/Flipboard/FLAnimatedImage

怎樣1句話添加上拉刷新?

https://github.com/samvermette/SVPullToRefresh

1
2
3
4
[tableView addPullToRefreshWithActionHandler:^{
// prepend data to dataSource, insert cells at top of table view
// call [tableView.pullToRefreshView stopAnimating] when done
} position:SVPullToRefreshPositionBottom];

怎樣把tableview里cell的小對勾的色彩改成別的色彩?

1
_mTableView.tintColor = [UIColor redColor];

04.png

本來我的statusbar是lightcontent的,結果用UIImagePickerController會致使我的statusbar的樣式變成黑色,怎樣辦?

1
2
3
4
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}

怎樣把我的navigationbar弄成透明的而不是帶模糊的效果?

1
2
3
4
[self.navigationBar setBackgroundImage:[UIImage new]
                         forBarMetrics:UIBarMetricsDefault];
self.navigationBar.shadowImage = [UIImage new];
self.navigationBar.translucent = YES;

怎樣改變uitextfield placeholder的色彩和位置?

繼承uitextfield,重寫這個方法

1
2
3
4
- (void) drawPlaceholderInRect:(CGRect)rect {
    [[UIColor blueColor] setFill];
    [self.placeholder drawInRect:rect withFont:self.font lineBreakMode:UILineBreakModeTailTruncation alignment:self.textAlignment];
}

你為何知道這么多奇怪的花招?

去stackoverflow刷問題啊,少年!




能不能只用1個pan手勢來代替UISwipegesture的各個方向?

1
2
3
4
5
6
7
8
9
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
- (void)pan:(UIPanGestureRecognizer *)sender
{
 
typedef NS_ENUM(NSUInteger, UIPanGestureRecognizerDirection) {
    UIPanGestureRecognizerDirectionUndefined,
    UIPanGestureRecognizerDirectionUp,
    UIPanGestureRecognizerDirectionDown,
    UIPanGestureRecognizerDirectionLeft,
    UIPanGestureRecognizerDirectionRight
};
 
static UIPanGestureRecognizerDirection direction = UIPanGestureRecognizerDirectionUndefined;
 
switch (sender.state) {
 
    case UIGestureRecognizerStateBegan: {
 
        if (direction == UIPanGestureRecognizerDirectionUndefined) {
 
            CGPoint velocity = [sender velocityInView:recognizer.view];
 
            BOOL isVerticalGesture = fabs(velocity.y) > fabs(velocity.x);
 
            if (isVerticalGesture) {
                if (velocity.y > 0) {
                    direction = UIPanGestureRecognizerDirectionDown;
                } else {
                    direction = UIPanGestureRecognizerDirectionUp;
                }
            }
 
            else {
                if (velocity.x > 0) {
                    direction = UIPanGestureRecognizerDirectionRight;
                } else {
                    direction = UIPanGestureRecognizerDirectionLeft;
                }
            }
        }
 
        break;
    }
 
    case UIGestureRecognizerStateChanged: {
        switch (direction) {
            case UIPanGestureRecognizerDirectionUp: {
                [self handleUpwardsGesture:sender];
                break;
            }
            case UIPanGestureRecognizerDirectionDown: {
                [self handleDownwardsGesture:sender];
                break;
            }
            case UIPanGestureRecognizerDirectionLeft: {
                [self handleLeftGesture:sender];
                break;
            }
            case UIPanGestureRecognizerDirectionRight: {
                [self handleRightGesture:sender];
                break;
            }
            default: {
                break;
            }
        }
        break;
    }
 
    case UIGestureRecognizerStateEnded: {
        direction = UIPanGestureRecognizerDirectionUndefined;   
        break;
    }
 
    default:
        break;
}
 
}

拉伸圖片的時候怎樣才能讓圖片不變形?

1. UIImage *image = [[UIImage imageNamed:@"xxx"] stretchableImageWithLeftCapWidth:10 topCapHeight:10];
(剛才有人提示這個已deprecated了哈,現在的方法叫resizableImageWithCapInsets).  

2.以下操作:

647444DE2635CA3F2A9951440C592A2A_ORIG_662_757.gif

怎樣播放GIF的時候這么卡,有無好點的庫?

FlipBoard出品的太合適你了。https://github.com/Flipboard/FLAnimatedImage  

怎樣1句話添加上拉刷新?

https://github.com/samvermette/SVPullToRefresh

1
2
3
4
[tableView addPullToRefreshWithActionHandler:^{
// prepend data to dataSource, insert cells at top of table view
// call [tableView.pullToRefreshView stopAnimating] when done
} position:SVPullToRefreshPositionBottom];

怎樣把tableview里cell的小對勾的色彩改成別的色彩?

_mTableView.tintColor = [UIColor redColor];

85E2955C50F62956F9158276B071925C_B1280_1280_754_98.png

本來我的statusbar是lightcontent的,結果用UIImagePickerController會致使我的statusbar的樣式變成黑色,怎樣辦?

1
2
3
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { 
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 
}

怎樣把我的navigationbar弄成透明的而不是帶模糊的效果?

1
2
[self.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault]; self.navigationBar.shadowImage = [UIImage new]; 
self.navigationBar.translucent = YES;

怎樣改變uitextfield placeholder的色彩和位置?

繼承uitextfield,重寫這個方法

1
2
3
4
- (void) drawPlaceholderInRect:(CGRect)rect { 
    [[UIColor blueColor] setFill]; 
    [self.placeholder drawInRect:rect withFont:self.font lineBreakMode:UILineBreakModeTailTruncation alignment:self.textAlignment]; 
}

你為何知道這么多奇怪的花招?

去stackoverflow刷問題啊,少年!








CGfloat和float的區分?

現在上架的app都要求支持64位系統,那末CGFloat和float的區分就在這里.command+左鍵點擊CGFloat.

1
typedef CGFLOAT_TYPE CGFloat;

這里可以看到CGFloat是CGFLOAT_TYPE的宏定義,那末這個又是甚么?

1
2
3
4
5
6
7
8
9
10
11
#if defined(__LP64__) && __LP64__
# define CGFLOAT_TYPE double
# define CGFLOAT_IS_DOUBLE 1
# define CGFLOAT_MIN DBL_MIN
# define CGFLOAT_MAX DBL_MAX
#else
# define CGFLOAT_TYPE float
# define CGFLOAT_IS_DOUBLE 0
# define CGFLOAT_MIN FLT_MIN
# define CGFLOAT_MAX FLT_MAX
#endif

這段話的意思就是,64位系統下,CGFLOAT是double類型,32位系統下是float類型.CGFloat能夠保證你的代碼在64位系統下也不容易出錯,所以你的代碼應當盡可能使用CGFloat.雖然他可能造成1些過剩的消耗.不過能保證安全.

應當使用FOUNDATION_EXPORT還是#define來定義常量?

1般iOS我們定義常量的方法有兩種,來看下面例子

我的.h文件

1
2
FOUNDATION_EXPORT NSString * const kMyConstantString;  
FOUNDATION_EXPORT NSString * const kMyConstantString2;

.m文件是這樣定義的

1
2
NSString * const kMyConstantString = @"Hello";
NSString * const kMyConstantString2 = @"World";

還有1種是經常使用的#define方法了

1
#define kMyConstantString @"Hello"

有甚么區分呢?

使用第1種方法在檢測字符串的值是不是相等的時候更快.對第1種你可以直接使用(stringInstance == MyFirstConstant)來比較,而define則使用的是這類.([stringInstance isEqualToString:MyFirstConstant])

哪一個效力高,不言而喻了.第1種直接比較的是指針地址,而第2個則是逐一比較字符串的每個字符是不是相等.

static inline function是干嗎的?

如果你的.m文件需要頻繁調用1個函數,可以用static inline來聲明,這相當于把函數體當作1個大號的宏定義.不過這也不是百分之百有效,到底能不能把函數體轉換為大號宏定義來用要看編譯器心情,它要是覺得你的方法太復雜,他就不轉了.他直接調用函數.

類似這類簡單函數他肯定是樂意的.

1
static inline CGRect ScaleRect(CGRect rect, float n)

這究竟是甚么鬼?static void *CapturingStillImageContext = &CapturingStillImageContext;

這類聲明方式經常使用于kvo,用來當作contenxt的key來添加.例如

1
[self addObserver:self forKeyPath:@"stillImageOutput.capturingStillImage" options:(NSKeyValueObservingOptionOld | NSKeyValueObservingOptionNew) context:CapturingStillImageContext];

這類聲明方式可以致使a method to create a unique pointer at compile time.在編譯的時候創建1個唯1的指針.由于kvo的時候context如果不謹慎重復了,會產生奇怪的事情.用這類方式可以免.

如何快速定位crash的位置?

041.png

選擇Add Exception Breakpoint

042.png

這樣如果你的app再crash就會自動定位到那句話.

最快速的提升流暢度的方法?

用instrument找出所有不需要透明但是透明的view,layer.全部弄成不透明的.

043.png

<
生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 黄视频在线免费看 | 国产免费小视频 | 国产青青草 | 精品一区二区三区成人精品 | 日韩精品一区在线观看 | 久久久久久亚洲精品 | 日韩视频在线播放 | 日韩专区av| 午夜毛片免费看20次 | 久久久久久亚洲精品视频 | 成人免费视频网站在线观看 | 精品一区久久久 | 久久久国产精品一区二区三区 | 国产日韩在线视频 | 国产在线视频一区 | 免费在线a | 亚洲国产v | 国产日韩视频 | 成人免费大片黄在线播放 | 不用播放器的av网站 | 91精品国产91久久久久久 | 91偷拍视频 | 日本精品视频一区二区 | 色网站免费在线 | 国产色网站| 日韩久久久久久 | 欧美日韩福利 | 91美女福利视频 | 涩视频 | 日韩精品一区二区三区四区视频 | 欧美日韩精品综合 | 精品国产青草久久久久福利 | 日本免费视频在线观看 | 99久久网 | 国产日韩精品一区 | 91在线一区二区三区 | 波多野结衣精品在线 | 亚洲精品在线观 | 免费日韩av| 91av导航| 国产爽视频 |