小编Edu*_*lho的帖子

UIImagePickerController cameraViewTransform在iOS 4中的行为有所不同

我将我的iPhone和SDK升级到iOS 4.0.1,现在我的应用程序运行方式与在iOS 3.x中运行的方式不同.

我的应用程序使用UIImagePickerController与自定义cameraOverlayView(我将在这篇文章中压制).重点是我需要在全屏模式下看到iphone相机.为了直接解决这个问题,我会提供一些代码和截图来解释发生了什么.

我创建了一个基于视图的应用程序中使用名为"CameraTransform" Xcode的模板项目,所以我得到了两个类:CameraTransformAppDelegateCameraTransformViewController,OK!在我CameraTransformViewControllerviewDidAppear方法中,我输入以下代码:

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];

    UIImagePickerController* picker = [[UIImagePickerController alloc] init];

    picker.sourceType = UIImagePickerControllerSourceTypeCamera;        
    picker.delegate = self;

    //[self configurePicker_FirstAttempt:picker];   Use this!
    //[self configurePicker_SecondAttempt:picker];  Use this too!

    [self presentModalViewController:picker animated:YES];
}

- (void)configurePicker_FirstAttempt:(UIImagePickerController*) picker {
    picker.showsCameraControls = NO;
    picker.navigationBarHidden = YES;

    // not needed (use defaults)
    //picker.toolbarHidden = YES;
    //picker.wantsFullScreenLayout = YES;
}

- (void)configurePicker_SecondAttempt:(UIImagePickerController*) picker {

    // Transform values for full screen support
    CGFloat cameraTransformX = …
Run Code Online (Sandbox Code Playgroud)

iphone camera transform uiview uiimagepickercontroller

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

UIView,它的超级视图和touchesBegan:

假设我有一个UIViewController子类来处理一些UIViews.这些UIViews被添加为UIViewController view属性的子视图):

UIViewController中:

- (void)viewDidLoad {
    UIImageView *smallImageView...
    [self.view addSubview:smallImageView];

    UIButton *button..
    [self.view addSubview:button];

    UIView *bigUIView.. // covers the entire screen (frame = (0.0, 0.0, 1024.0, 768.0))
    [self.view addSubview:bigUIView];
...
}
Run Code Online (Sandbox Code Playgroud)

AFAIK,因为它bigUIView是最前面的视图并覆盖整个屏幕,它将接收touchesBegan:withEvent:和其他视图,例如button不会接收任何触摸事件.

在我的应用程序中bigUIView必须是最顶层的视图,因为它包含主要的用户界面对象(CALayers,实际上是主要的游戏对象),在动画时,必须位于所有其他辅助UI元素(UIButtons等)之上.但是,我希望能够在响应程序链中保留UIButtons和其他对象.

我尝试在bigUIView课堂上实现以下内容:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {    
    [self.superview touchesBegan:touches withEvent:event];

    ... hit test the touch for this specific uiview..
}
Run Code Online (Sandbox Code Playgroud)

笔记:

  1. bigUIView的superview引用了UIViewController的view属性,它是否将触摸事件传播到它的所有子视图?
  2. bigUIView必须有,userInteractionEnabled = YES因为它也处理用户输入.
  3. 我无法将button/ smallImageView带到前面,因为它会出现在主要游戏对象(子层 …

iphone touch uiview ipad uiresponder

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

显示文档时没有复制/粘贴和选择矩形的UIWebView

在我的应用程序中,我想禁用UIWebView对象显示的内容的复制/粘贴/剪切.为此,我创建了一个UIWebView子类并覆盖了该- (BOOL)canPerformAction:(SEL)action withSender:(id)sender方法:

#pragma mark - UIResponderStandardEditActions 

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {    
    if (action == @selector(copy:) ||
        action == @selector(paste:)||
        action == @selector(cut:)) {
        return _copyCutAndPasteEnabled;
    }

    return [super canPerformAction:action withSender:sender];
}
Run Code Online (Sandbox Code Playgroud)

现在用户不再可以进行此类操作,但UIWebView仍显示"选择矩形",如以下屏幕截图所示:

选择矩形

注意:UIWebView中显示的内容不是HTML页面.我正在显示文件文件(PDF,DOC,PPT),使用以下文件从文件加载:

NSURL *fileURL = [NSURL fileURLWithPath:<document file path..>];
NSURLRequest *fileRequest = [NSURLRequest requestWithURL:fileURL];
[<uiwebView> loadRequest:fileRequest];
Run Code Online (Sandbox Code Playgroud)

有没有办法禁用/隐藏这个选择矩形功能?

[] S,

iphone selection uiwebview ipad uiresponder

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

如何从Json字符串中删除所有空格

可能重复:
有效地从字符串中删除所有空格
在.NET中缩小缩进的JSON字符串

我有一个像这样的字符串:

{"languages" : [{"fluency": 4, "id": 15}], "address" : {"city_id" : 8341, "city_name" : "My city"}, "about" : null, "birthday" : "1988-03-18", "email" : "email@a.com", "id" : 3, "income" : 4}
Run Code Online (Sandbox Code Playgroud)

我想要一个紧凑/缩小的字符串,如下所示:

{"languages":[{"fluency":4,"id":15}],"address":{"city_id":8341,"city_name":"My city"},"about":null,"birthday":"1988-03-18","email":"email@a.com","id":3,"income":4}
Run Code Online (Sandbox Code Playgroud)

注意:

  • 我正在使用内置功能System.Json在我的应用程序中执行序列化.我JsonValue使用该ToString ()方法检索对象的字符串表示,但看起来我无法控制输出字符串的格式.
  • 我想使用辅助方法来"缩小"JSON字符串.我不想在项目中包含另一个第三方Json库.
  • 我正在使用复杂的JSON数据结构(包括嵌套对象/数组)
  • 我使用的是Mono,而不是.NET

c# string mono serialization json

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

Unity - 由于CryptographicException,无法发送HTTPS请求

我正在尝试向我的远程服务器发送https请求,但我总是遇到以下异常:

Exception: System.IO.IOException: The authentication or decryption has failed. ---> System.ArgumentException: certificate ---> System.Security.Cryptography.CryptographicException: Unsupported hash algorithm: 1.2.840.113549.1.1.11
  at Mono.Security.X509.X509Certificate.VerifySignature (System.Security.Cryptography.RSA rsa) [0x00000] in <filename unknown>:0 
  at Mono.Security.X509.X509Certificate.VerifySignature (System.Security.Cryptography.AsymmetricAlgorithm aa) [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Chain.IsSignedWith (System.Security.Cryptography.X509Certificates.X509Certificate2 signed, System.Security.Cryptography.AsymmetricAlgorithm pubkey) [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Chain.Process (Int32 n) [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Chain.ValidateChain (X509ChainStatusFlags flag) [0x00000] in <filename unknown>:0 
  at System.Security.Cryptography.X509Certificates.X509Chain.Build (System.Security.Cryptography.X509Certificates.X509Certificate2 certificate) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Security.Cryptography.X509Certificates.X509Chain.Build …
Run Code Online (Sandbox Code Playgroud)

mono ssl https certificate unity-game-engine

6
推荐指数
1
解决办法
9692
查看次数

Facebook Share对话框始终仅在Android上显示Captcha

我有一个具有"共享"功能的跨平台应用程序(iOS/Android/Web)."共享"功能在iOS和Web版本上运行良好,但在Android平台上,Facebook在呈现共享表单之前始终向用户显示"安全检查"验证码:

验证码

传递给FB.Feed的参数如下:

  • 链接: "http://apps.facebook.com/<my_app_id>"
  • linkName :( "Solitaire"我的应用名称)
  • 图片: "http://casual-solitaire.herokuapp.com/Resources/Facebook/ShareIcon-128x128.png"

这里有两件奇怪的事情:

  1. Captcha只发生在Android上
  2. 如果我使用完全相同的参数FB.Feed但更改<my_app_id>为另一个应用程序,则验证码会消失(我使用我发布的另一个应用程序中的应用程序ID对其进行测试).

看起来我的应用ID是"黑名单",有谁知道我该怎么做才能解决这个问题?

captcha android share facebook unity-game-engine

6
推荐指数
1
解决办法
631
查看次数

多个CAKeyframeAnimation同时在不同的层中

现在有人如何使用CAKeyframeAnimation同时为多个图层设置动画?每个图层都有自己的CAKeyframeAnimation对象.看看下面的代码:

我有一个接收对象的方法,创建CAKeyframeAnimation并将动画附加到它:

- (void)animateMovingObject:(CALayer*)obj
               fromPosition:(CGPoint)startPosition
                 toPosition:(CGPoint)endPosition
                   duration:(NSTimeInterval)duration {
    CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    pathAnimation.calculationMode = kCAAnimationPaced;
    //pathAnimation.fillMode = kkCAFillModeRemoved; // default 
    //pathAnimation.removedOnCompletion = YES; // default
    pathAnimation.duration = duration;

    // create an empty mutable path
    CGMutablePathRef curvedPath = CGPathCreateMutable();

    // set the starting point of the path
    CGPathMoveToPoint(curvedPath, NULL, startPosition.x, startPosition.y);

    CGPathAddCurveToPoint(curvedPath, NULL, 
                          startPosition.x, endPosition.y, 
                          startPosition.x, endPosition.y,
                          endPosition.x, endPosition.y);
    pathAnimation.path = curvedPath;
    [obj addAnimation:pathAnimation forKey:@"pathAnimation"];
    CGPathRelease(curvedPath);
}
Run Code Online (Sandbox Code Playgroud)

现在,假设我在我的棋盘游戏中添加了3层作为子层,我进行了以下调用:

CALayer obj1 = ... // set up layer and add as sublayer …
Run Code Online (Sandbox Code Playgroud)

iphone core-animation ipad

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

Mono for Android - 所有活动均以纵向为主题

我有一个MonoDroid应用程序,我想强制我的所有活动只在纵向方向呈现.

我想创建一个Activity base classe,例如:

[Activity (ScreenOrientation = ScreenOrientation.Portrait)]         
public abstract class BaseActivity : Activity
{
}
Run Code Online (Sandbox Code Playgroud)

我的应用程序中的所有其他活动应该继承它(也避免重复,并有一个中心位置来定义ScreenOrientation = ScreenOrientation.Portrait).

但是,如果查看ActivityAttribute定义,看起来它不支持继承.

[Serializable]
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
public sealed class ActivityAttribute : Attribute { ... }
Run Code Online (Sandbox Code Playgroud)
  1. 我是否必须Activity (ScreenOrientation = ScreenOrientation.Portrait)在我的应用程序中进行所有活动?
  2. 在Android世界中仅支持Portrait方向是一个坏主意吗?(我有一个仅适用于肖像的iOS应用程序,它可以很好地工作,不需要在横向上运行).

android orientation xamarin.android android-activity xamarin

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

Android启动器图标 - 是我的默认/ mdpi资源减少量?

我是新来的Android开发(使用单声道Android版),我读过, 和其他一些问题上的SO这里,但我不知道如何提供所有必要的文件图标我的应用程序.

  1. 从模板项目中,IDE为我创建了一个drawable/包含48x48 px Icon.png文件的文件夹.
  2. 由于我需要提供替代资源,我抓取了一个PNG文件作为我的应用程序图标并使用了Android Asset Studio(在文档中提到),它为我生成了以下文件:

drawable-hdpi/ic_launcher.png (72x72像素)

drawable-mdpi/ic_launcher.png (48x48像素)

drawable-xhdpi/ic_launcher.png (96x96像素)

drawable-xxhdpi/ic_launcher.png (144x144像素)

(我不知道为什么,但Android Asset Studio没有生成ldpi版本,所以我自己调整了36x36图标.)

现在我迷路了

1.我应该维持既有48x48像素的副本drawable-mdpi/drawable/

如果我只保留图标drawable-mdpi/,那么应用程序可能会在Android的旧设备/版本上崩溃(因为缺少默认资源)?1.如果我只在drawable/(后备)中保留图标,那么使用的重点是什么drawable-mdpi/

由于我不确切知道该怎么做,我将项目可绘制文件夹保留如下:

drawable/ic_launcher.png (48x48像素)

drawable-hdpi/ic_launcher.png (72x72像素)

drawable-ldpi/ic_launcher.png (36x36像素)

drawable-mdpi/ic_launcher.png (48x48像素)

drawable-xhdpi/ic_launcher.png (96x96像素)

drawable-xxhdpi/ic_launcher.png (144x144像素)

但对我来说仍然不清楚.


编辑:

如果我提供所有可能的"替代"资源,那么default(drawable/)资源文件夹将变为冗余,因此我可以删除它.但是我不愿意提供默认资源,因为做相反的事情似乎更合理:首先提供"默认"资源,然后根据需要提供"替代"资源.

resources icons android launch mdpi

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

Monotouch应用程序中的线程数

我在经常被调用的场景中使用TaskTaskCompletionSource编写应用程序代码,例如从“滚动表视图”异步从Internet下载图像。这使我可以编写异步/等待代码,而无需触摸UI线程进行下载/缓存操作。

例如:

public override Task<object> GetCachedImage (string key)
    {
        UIImage inMemoryImage = sdImageCache.ImageFromMemoryCache (key);

        //
        // Return synchronously since the image was found in the memory cache.
        if (inMemoryImage != null) {
            return Task.FromResult ((object)inMemoryImage);
        }

        TaskCompletionSource<object> tsc = new TaskCompletionSource<object> ();

        //
        // Query the disk cache asynchronously, invoking the result asynchronously.
        sdImageCache.QueryDiskCache (key, (image, cacheType) => {
            tsc.TrySetResult (image);
        });

        return tsc.Task;
    }
Run Code Online (Sandbox Code Playgroud)

GetCachedImage多次调用,因为表视图中可能有大量的图片被下载,并且用户可以滚动表格视图。Task本身不需要花费太长时间即可执行(在某些情况下,结果是同步返回的),因此我希望系统创建很多线程,但也可以重用它们。但是我在控制台中看到以下输出:

Thread finished: <Thread Pool> #149

线程数总是越来越大,我担心我的应用程序创建了太多线程,并且可能在长时间使用后被卡住。什么Thread finished: …

c# mono xamarin.ios async-await xamarin

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