小编Kor*_*pel的帖子

React Native AsyncStorage在渲染后获取数据

我正在使用AsyncStoragein ComponentWillMount来获取本地存储accessToken,但它在render()函数运行后返回promise .如何render()在承诺完成之前等待?谢谢.

react-native

34
推荐指数
2
解决办法
2万
查看次数

CGAffineTransformInvert:奇异矩阵错误

我在Xcode中创建了Universal App(单一视图).因为我想iAd在每个视图上都有横幅,我将此代码添加到AppDelegate文件中:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
    if var root = self.window?.rootViewController
    {
        let contentFrame = UIScreen.mainScreen().bounds
         var _banner = ADBannerView(adType: ADAdType.Banner)

        _banner.frame=CGRectMake(0, contentFrame.height - _banner.frame.height, _banner.frame.width, _banner.frame.height)
        _banner.delegate = self
        root.view.addSubview(_banner)
    }

    return true
}
Run Code Online (Sandbox Code Playgroud)

在真正的iPhone(iOS 8)上一切正常(横幅出现在每个视图上)但我收到此错误:

<Error>: CGAffineTransformInvert: singular matrix.
Run Code Online (Sandbox Code Playgroud)

如果我尝试在模拟器(iOS 8)上运行此应用程序,行为是相同的.一切正常,我得到相同的错误,但我得到:*ADBannerView:

 Unhandled error (no delegate or delegate does not implement didFailToReceiveAdWithError:):
 Error Domain=ADErrorDomain Code=7 "The operation couldn’t be completed. Ad was unloaded from 
this banner" UserInfo=0x7b83bf30 {ADInternalErrorCode=7, ADInternalErrorDomain=ADErrorDomain, …
Run Code Online (Sandbox Code Playgroud)

ios iad swift swift2

10
推荐指数
1
解决办法
1万
查看次数

如何告诉R6类如何处理方括号?

我有一个R6类,它具有属性a data.table.让我们说它看起来像这样:

library(R6)
library(data.table)

foo <- R6Class(
  classname = 'foo',
  public = list(
    dt = NA,
    initialize = function(dt) {
      self$dt <- dt
    }
  )
)

set.seed(123)
dt <- data.table(col1 = rnorm(10), col2 = rnorm(10))

bar <- foo$new(dt)
Run Code Online (Sandbox Code Playgroud)

我想这样做:

bar[<data.table stuff>]
Run Code Online (Sandbox Code Playgroud)

做这个:

bar$dt[<data.table stuff>]
Run Code Online (Sandbox Code Playgroud)

可能吗?

r data.table r6

9
推荐指数
1
解决办法
279
查看次数

Smalltalk/Pharo基于图像的持久性 - 如何部署?

我将如何实际部署使用基于图像的持久性的应用程序?这是我的场景:我在Smalltalk中编写CMS.在这种情况下,数据主要是读取的,很少写入.现在,每当有人写数据时,我都可以拍摄图像的快照.但是,我如何介绍我的应用程序的新版本并继续运行应用程序的状态?除了图像,我不需要某种形式的序列化/数据持久性吗?谢谢

smalltalk pharo

5
推荐指数
1
解决办法
194
查看次数

动态改变UIPageControl.appearance的点的背景颜色

我有一个UIPagevViewController用于显示 4 ViewControllers。我希望点背景颜色根据我当前使用的视图背景颜色进行更改。虽然我设法为点和第一页获得了相同的背景颜色,但我没有为其他每个页面都这样做。换句话说,我想根据显示的视图动态更改点背景

           import UIKit

            class PageViewController: UIPageViewController,UIPageViewControllerDelegate, UIPageViewControllerDataSource {

            //my 4 viewControllers used in the UIPageViewController
            fileprivate lazy var pages : [UIViewController] = {
                return [
                    self.getViewController(withIdentifier: "firstViewControllerID"),
                    self.getViewController(withIdentifier: "secondViewControllerID"),
                    self.getViewController(withIdentifier: "thirdViewControllerID"),
                    self.getViewController(withIdentifier: "differentViewController")

                ]
            }()

         //function that accesses those view controllers used above from the storyboard
            fileprivate func getViewController(withIdentifier identifier: String) -> UIViewController
                {
                    return UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: identifier)
                }
         /* needed function for the UIPageViewControllerDelegate, UIPageViewControllerDataSource protocols 
        func pageViewController(_ pageViewController: UIPageViewController, viewControllerBefore viewController: …
Run Code Online (Sandbox Code Playgroud)

uipagecontrol ios swift

4
推荐指数
1
解决办法
995
查看次数

仅当一个表达式中的可选项不为 nil 时才调用函数?

我知道可以这样做:

let intValue: Int? = rawValue == nil ? Int(rawValue) : nil
Run Code Online (Sandbox Code Playgroud)

或者甚至像这样:

var intValue: Int?

if let unwrappedRawValue = rawValue {
    intValue = Int(unwrappedRawValue)
}
Run Code Online (Sandbox Code Playgroud)

不过我想知道是否有一种方法可以在一个表达式中做到这一点,如下所示:

let intValue: Int? = Int(rawValue) // Where Int() is called only if rawValue is not nil
Run Code Online (Sandbox Code Playgroud)

swift optional-binding option-type

3
推荐指数
1
解决办法
1202
查看次数