Light's Blog

The best or nothing.

iOS知识小集-180903

| Comments

集成Apple Pay

权限配置

按官方指导配置权限。

调用过程

引入<PassKit/PassKit.h>,权限判断,支付卡判断,设置商品参数,创建支付请求,显示支付界面,代理接收结果。

iOS知识小集-180827

| Comments

lldb

什么是lldb

LLDB是个开源的内置于XCode的具有REPL(read-eval-print-loop)特征的Debugger,其可以安装C++或者Python插件。

iOS知识小集-180820

| Comments

获取textview光标所在位置

1
2
3
4
5
6
7
- (NSUInteger)currentLocation:(UITextView*)textView{
  NSRange range = textView.selectionRange;
  if (range.location == NSNotFound) {
    return textView.text.length;
  }
  return range.location;
}

iOS知识小集-180813

| Comments

动画结束后使layer保持动画后的状态

需要同时设置animation.removedOnCompletion = NOanimation.fillMode = kCAFillModeForwards

iOS知识小集-180806

| Comments

APP灰度发布

可以配置APP灰度发布。

Today Extension

scroll is disabled

Adding scrolls into a widget, both vertical and horizontal, is not possible. Or more precisely, adding a scroll view is possible but scrolling won’t work. Horizontal scrolling gesture in a scroll view in the Today extension will be intercepted by the notification center which will cause scrolling from Today to the Notification center. Scrolling vertically a scroll view inside a Today extension will be interrupted by scrolling the Today’s View.
A Tutorial on iOS 8 App Extensions

数据共享

需要在主工程的entitlements中添加APP groups

资源共享

在today extension target中 copy bundle resources

高度

折叠高度110,展开高度最大值限制。

Can’t add self as subview

连续push两次会导致该问题。

iOS知识小集-180730

| Comments

UIImpactFeedbackGenerator

1
2
3
4
5
6
7
8
9
10
11
12
13
- (UIImpactFeedbackGenerator *)impactFeedback{
  if (!_impactFeedback) {
    _impactFeedback = [[UIImpactFeedbackGenerator alloc] initWithStyle:UIImpactFeedbackStyleLight];
  }
  return _impactFeedback;
}

- (void)occurImpactFeedback{
  if (@available(iOS 10.0, *)) {
    [self.impactFeedback prepare];
    [self.impactFeedback impactOccurred];
  }
}

XCode屏蔽控制台多余系统信息

Edit Scheme –> Arguments –> Environment Variables –> OS_ACTIVITY_MODE = disable