我将我的iPhone和SDK升级到iOS 4.0.1,现在我的应用程序运行方式与在iOS 3.x中运行的方式不同.
我的应用程序使用UIImagePickerController与自定义cameraOverlayView(我将在这篇文章中压制).重点是我需要在全屏模式下看到iphone相机.为了直接解决这个问题,我会提供一些代码和截图来解释发生了什么.
我创建了一个基于视图的应用程序中使用名为"CameraTransform" Xcode的模板项目,所以我得到了两个类:CameraTransformAppDelegate和CameraTransformViewController,OK!在我CameraTransformViewController的viewDidAppear方法中,我输入以下代码:
- (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) 假设我有一个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)
笔记:
bigUIView的superview引用了UIViewController的view属性,它是否将触摸事件传播到它的所有子视图?bigUIView必须有,userInteractionEnabled = YES因为它也处理用户输入.button/ smallImageView带到前面,因为它会出现在主要游戏对象(子层 …在我的应用程序中,我想禁用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,
我有一个像这样的字符串:
{"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 ()方法检索对象的字符串表示,但看起来我无法控制输出字符串的格式.我正在尝试向我的远程服务器发送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) 我有一个具有"共享"功能的跨平台应用程序(iOS/Android/Web)."共享"功能在iOS和Web版本上运行良好,但在Android平台上,Facebook在呈现共享表单之前始终向用户显示"安全检查"验证码:

传递给FB.Feed的参数如下:
"http://apps.facebook.com/<my_app_id>""Solitaire"我的应用名称)"http://casual-solitaire.herokuapp.com/Resources/Facebook/ShareIcon-128x128.png"这里有两件奇怪的事情:
FB.Feed但更改<my_app_id>为另一个应用程序,则验证码会消失(我使用我发布的另一个应用程序中的应用程序ID对其进行测试).看起来我的应用ID是"黑名单",有谁知道我该怎么做才能解决这个问题?
现在有人如何使用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) 我有一个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)
Activity (ScreenOrientation = ScreenOrientation.Portrait)在我的应用程序中进行所有活动?android orientation xamarin.android android-activity xamarin
我是新来的Android开发(使用单声道Android版),我读过这,这 这和其他一些问题上的SO这里,但我不知道如何提供所有必要的文件图标我的应用程序.
drawable/包含48x48 px Icon.png文件的文件夹.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/)资源文件夹将变为冗余,因此我可以删除它.但是我不愿意提供默认资源,因为做相反的事情似乎更合理:首先提供"默认"资源,然后根据需要提供"替代"资源.
我在经常被调用的场景中使用Task和TaskCompletionSource编写应用程序代码,例如从“滚动表视图”异步从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: …
iphone ×4
android ×3
ipad ×3
mono ×3
c# ×2
uiresponder ×2
uiview ×2
xamarin ×2
async-await ×1
camera ×1
captcha ×1
certificate ×1
facebook ×1
https ×1
icons ×1
json ×1
launch ×1
mdpi ×1
orientation ×1
resources ×1
selection ×1
share ×1
ssl ×1
string ×1
touch ×1
transform ×1
uiwebview ×1
xamarin.ios ×1