小编use*_*522的帖子

animationControllerForPresentedController未调用

我正在尝试创建一个自定义动画来转换像新钱包应用程序中的控制器.

我有一个像这样的ViewController:

@interface ViewController () <UIViewControllerTransitioningDelegate>
@property (nonatomic, strong) UILabel *testLabel;
@property (nonatomic, strong) UIButton *button;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];
    self.transitioningDelegate = self;

    _testLabel = [[UILabel alloc] init];
    _testLabel.text = @"View 1";

    [self.view addSubview:_testLabel];



    [_testLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(self.view);
        make.height.equalTo(@50);
        make.centerX.equalTo(self.view);
        make.top.equalTo(self.mas_topLayoutGuide);
    }];

    _button = [[UIButton alloc] init];
    [_button addTarget:self action:@selector(push)forControlEvents:UIControlEventTouchUpInside];
    [_button setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [_button setTitle:@"Show View" forState:UIControlStateNormal];
    [self.view addSubview:_button];

    [_button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(self.view);
        make.width.and.height.equalTo(@50);
    }];
}

- (void)push { …
Run Code Online (Sandbox Code Playgroud)

objective-c ios

4
推荐指数
2
解决办法
3760
查看次数

用其他颜色动画填充UIImageView

我有一个imageview,我想让imageview以彩色动画.所以我的图像首先是绿色图像,然后我想将其设置为橙色图像.

这是我的代码:

class TestView: UIView {

    func startAnimate(){

        let size:CGSize = self.bounds.size

        let layer = UIImageView(image: UIImage(named: "LaunchIcon"))
        layer.frame = self.bounds

        let initialRect:CGRect = CGRect.init(x: 0, y: size.height, width: size.width, height: 0)
        let finalRect:CGRect = CGRect.init(x: 0, y: size.height, width: size.width, height: size.height)

        let sublayer = CALayer()
        sublayer.frame = initialRect
        sublayer.backgroundColor = UIColor.orange.cgColor
        sublayer.opacity = 0.5


        let mask:CAShapeLayer = CAShapeLayer()
        mask.frame = self.bounds
        mask.path = UIBezierPath(rect: self.bounds).cgPath
        mask.fillColor = UIColor.black.cgColor

        layer.layer.addSublayer(sublayer)
        layer.layer.mask = mask

        self.layer.addSublayer(layer.layer)

        let boundsAnim:CABasicAnimation  = CABasicAnimation(keyPath: "bounds") …
Run Code Online (Sandbox Code Playgroud)

core-animation ios swift3

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

创建一个新的列表,每个值都有差异

我正在尝试创建一个执行以下操作的函数:它获取一个列表,例如[1,4,2,3],它返回一个列表[3,2,1].

因为1 - 4 = 3(绝对值),4 - 2 = 22 - 3 = 1.

我认为除了abs值之外,这段代码会做到这一点.

function :: [a] -> [a]
function [] = []
function (x:xs) = [x - head(xs)] ++ function xs
Run Code Online (Sandbox Code Playgroud)

但它给了我错误,我找不到任何解决方案.

亲切的问候,

编辑:

谢谢你们,今天学到了很多东西.确实我是初学者,我正在上大学课程,给我prolog,haskell,scala,python,aspectj和metaprogramming.所以我们每个课程有2个小时的课程,之后有一段时间可以做一些练习.

下周一我有考试和拉链等...我们必须编写自己的功能.但感谢良好的解释教程,学到了很多东西.这是工作解决方案:

function :: Num a => [a] -> [a]
function (x:y:xs) = [abs(x - y)] ++ function (y:xs)
function _ = []
Run Code Online (Sandbox Code Playgroud)

haskell

3
推荐指数
2
解决办法
217
查看次数

列出设备上具有特定扩展名的所有文件

我想在设备上找到所有文件,在我的情况下是 pdf。现在我写了这段代码:

File images = Environment.getExternalStorageDirectory();
        mImagelist = images.listFiles(new FilenameFilter(){
            public boolean accept(File dir, String name)
            {
                return ((name.endsWith(".pdf")));
            }
        });
Run Code Online (Sandbox Code Playgroud)

此代码仅找到一个 pdf
/storage/emulated/0/HTC_One_WWE_User_Guide.pdf。我的下载文件夹中还有其他几个 pdf。

我该如何解决这个问题?

android android-file android-external-storage

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

NSLocalizedString 给出其他语言,然后电话在

我的项目基础语言是英语。我的模拟器/手机是英文的。这些项目支持英语、法语、荷兰语。

当应用程序第一次启动时,即使手机是英文的,应用程序也始终是法语。

当我调试并打印出这一行时:

[NSLocale preferredLanguages][0];
Run Code Online (Sandbox Code Playgroud)

它给了我正确的语言,即英语。

有人知道这是为什么吗?

objective-c nslocalizedstring ios

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

将 .so 文件添加到 android studio 时出现 UnsatisfiedLinkError

我正在尝试在我的 android studio 项目中包含https://github.com/GerardSoleCa/Robosodium。我正在运行 Android Studio 1.4.1

我用编译的 .so 文件创建了一个 jniLibs 文件夹。我在我的主要活动中初始化了这个库,如下所示:

static {
    System.loadLibrary("libkaliumjni");
}
Run Code Online (Sandbox Code Playgroud)

当我运行项目时,我得到了这个:

java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/be.example.libtest-1/base.apk"],nativeLibraryDirectories=[/data/app/be.example.libtest-1/lib/x86, /vendor/lib, /system/lib]]] couldn't find "liblibkaliumjni.so"
Run Code Online (Sandbox Code Playgroud)

我的文件夹结构是:

在此处输入图片说明

有人可以帮我弄这个吗?

编辑:

这是我的 build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "be.example.libtest"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:design:23.1.0' …
Run Code Online (Sandbox Code Playgroud)

java-native-interface android android-ndk android-studio

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

从非协议,非类Type继承

我想要一个数组的扩展,你可以在其中找到某种类型的项目.

我试过这样的:

  func findItem<U: Type>(itemToFind: U) -> AnyObject? {
    for item in self {
        if let obj = item as? itemToFind {
            return obj
        }
    }
    return nil
}
Run Code Online (Sandbox Code Playgroud)

所以我检查它是否是相同的类型,然后我想返回obj.

我得到的错误是:

从非协议,非类'Type'继承.

我怎么能解决这个问题,我可以传递给函数ViewController.self,如果找不到则返回nil或者数组中的viewcontroller?

generics swift

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

使用局部var计数的递归函数

我有一个关于递归函数的问题.

我已经制作了这个小例子程序来计算整数中的单个数字:例如:123 = 6因为1 + 2 + 3 = 6.

现在我用静态int和这个递归函数创建了它:

  static int totalNumbers(int a)
  { 
    if(a <= 0)
      return sum;
    else
    {
      sum += a % 10;
      return totalNumbers(a/10);
    }
  }
Run Code Online (Sandbox Code Playgroud)

这个功能就像魅力一样,但我的问题是,我可以在没有名为sum的静态int的情况下制作它吗?有没有办法可以在函数中定义一个整数和,让它们用本地var计算或者不可能?

亲切的问候,

java recursion

2
推荐指数
1
解决办法
196
查看次数

观看应用以错误clientIdentifier开头的interfaceControllerID找不到

我在watchos2上有一个smartwatch应用程序。该应用程序始终可以运行,但是现在启动时,我立即收到此错误:

Lop_WatchKit_Extension[17535:7854201] *********** ERROR -[SPRemoteInterface _interfaceControllerClientIDForControllerID:] clientIdentifier for interfaceControllerID:447E0002 not found
Run Code Online (Sandbox Code Playgroud)

我在这里找到了一些有关stackoverflow的主题,但没有任何解决方案。

objective-c ios watchos-2

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

Swagger UI空,并给出403

我正在使用spring boot并且我已经添加了swagger到我的依赖项:

<dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger2</artifactId>
        <version>2.8.0</version>
    </dependency>
    <dependency>
        <groupId>io.springfox</groupId>
        <artifactId>springfox-swagger-ui</artifactId>
        <version>2.8.0</version>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

我的配置:

@Configuration
@EnableSwagger2
public class SwaggerConfiguration {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }
}
Run Code Online (Sandbox Code Playgroud)

当我去这个网址时:

http:// localhost:8080/v2/api-docs它有效,我得到了json.

swagger ui http:// localhost:8080/swagger-ui.html

现在当我检查chrome中的网络选项卡时,我只是一个空页面,我看到了这个:

Failed to load resource: the server responded with a status of 403 ()
swagger-ui-standalone-preset.js Failed to load resource: the server responded with a status of 403 ()
swagger-ui.css Failed to load resource: the server responded with a status …
Run Code Online (Sandbox Code Playgroud)

swagger-ui spring-boot swagger-2.0

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