我希望将我的UIModalPresentationFormSheet样式模态视图设置为UIModalPresentationFullScreen某个时候的样式,但是当它已经显示为UIModalPresentationFormSheet样式时,它无法使用代码" [xx setModalPresentationStyle:UIModalPresentationFullScreen];" 转到全屏模式.
在显示模态视图后,有没有办法改变现在的风格?我的代码是这样的:
UITableDownload* vc = [[UITableDownload alloc] initWithStyle:UITableViewStylePlain];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
[nav setModalPresentationStyle:UIModalPresentationFormSheet];
[MainAppDelegate mainBrowserViewController] presentModalViewController:nav animated:YES];
...//after shown,sometime I implement following code:
[nav setModalPresentationStyle:UIModalPresentationFullScreen];//(The "nav" object is the same as above code)
//But the change style code takes no effect.
Run Code Online (Sandbox Code Playgroud) 有没有办法在C++中做到这一点,尤其是范围部分.
answer = (0..999).select { |a| a%3 ==0 || a%5==0 }
puts answer.inject { |sum, n| sum+n }
Run Code Online (Sandbox Code Playgroud)
我已经创建了自己的c ++解决方案,但使用了更标准的for循环,并想知道是否有更酷的方法来做到这一点?
我们有一个数据密集型系统.它存储原始数据,然后根据正确响应数/总试验数计算百分比.
最近我们有客户想要将旧数据导入我们的系统.
我需要一种方法将百分比转换为最接近的分数.
例子.
我意识到我可以将其计算为67/100,但这意味着当6个就足够时,我必须向系统添加100个数据点.
有没有人有任何想法?
EDIT Denominator可以是任何东西.他们给了我一个原始的,圆润的百分比,我试图尽可能接近RAW数据
我目前正在尝试将Xamarin.iOS应用程序库转换为PCL.我有这个不能编译的代码:
private void SetPrivateField<T>(object item, string fieldName, object value) {
typeof(T).GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic)
.SetValue(item, value);
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我正在尝试为类型设置私有字段.还有另外一种方法吗?
编辑 这编译.它会做同样的事情吗?
private void SetPrivateField<T>(object item, string fieldName, object value) {
typeof(T).GetRuntimeField(fieldName).SetValue(item,value);
}
Run Code Online (Sandbox Code Playgroud) 我目前正在尝试将Xamarin.iOS应用程序库转换为PCL(配置文件78).我有这个不能编译的代码:
public static void RegisterAllCommandHandlers(IEnumerable<Assembly> assemblies) {
// Get all types that are concrete classes which implement ICommandHandler
var commandHandlerOpenGenericType = typeof(ICommandHandler<>);
var types = new List<Type>();
foreach (var assembly in assemblies) {
types.AddRange(assembly.GetTypes()
.Where(x => x.IsClass && !x.IsAbstract && x.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == commandHandlerOpenGenericType)));
}
}
Run Code Online (Sandbox Code Playgroud)
这是编译器错误的图像:

如何使用新的反射API执行相同的操作?
我们正在系统中删除大量共享功能并将其移植到PCL库中.我在使用PCLCrypto时遇到了问题.我正在我们的数据库中获取一些现有数据,并尝试使用相同的算法对其进行解密.我得到了值,但最后有16个额外的字节只是垃圾.
请参阅下面的代码: 使用System.Security.Cryptography的旧算法
public static string SymmetricEncrypt(this string plaintext, string key, SymmetricAlgorithm algorithm)
{
byte[] keyBuffer = Convert.FromBase64String(key.Hash(HashAlgorithm.MD5));
byte[] plainTextBuffer = Encoding.UTF8.GetBytes(plaintext);
var symmetricAlgorithm = new AesCryptoServiceProvider();
symmetricAlgorithm.Key = keyBuffer;
symmetricAlgorithm.Mode = CipherMode.ECB;
var encryptor = symmetricAlgorithm.CreateEncryptor();
byte[] cipherBuffer = encryptor.TransformFinalBlock(plainTextBuffer, 0, plainTextBuffer.Length);
symmetricAlgorithm.Clear();
return Convert.ToBase64String(cipherBuffer);
}
public static string SymmetricDecrypt(this string cipherText, string key, SymmetricAlgorithm algorithm)
{
byte[] keyBuffer = Convert.FromBase64String(key.Hash(HashAlgorithm.MD5));
byte[] cipherTextBuffer = Convert.FromBase64String(cipherText);
var symmetricAlgorithm = new AesCryptoServiceProvider();
symmetricAlgorithm.Key = keyBuffer;
symmetricAlgorithm.Mode = CipherMode.ECB;
var decryptor = …Run Code Online (Sandbox Code Playgroud) 我正在寻找一个在objective-c中包含此代码的在线示例
-(void)dealloc {
[activeController viewWillDisappear:NO];
[activeController.view removeFromSuperview];
[activeController viewDidDisappear:NO];
[activeController release];
[super dealloc];
}
Run Code Online (Sandbox Code Playgroud)
我假设MT等价物将是Dispose,我是否正确?
我不需要打电话给:
[activeController release];
[super dealloc];
Run Code Online (Sandbox Code Playgroud)
方法,因为他们将收集在Monotouch上的垃圾,这也是正确的吗?
以下代码似乎偶尔会产生这种堆栈跟踪.在内部FileStream对象上调用dispose方法时,它看起来是在框架内发生的吗?对我来说似乎是一个错误,任何想法?
var previousVersion = long.Parse(File.ReadAllText(Paths.VersionFile));
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪:
System.IO.IOException: Invalid parameter
at System.IO.FileStream.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0
at System.IO.Stream.Close () [0x00000] in <filename unknown>:0
at System.IO.StreamReader.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0
at System.IO.TextReader.Dispose () [0x00000] in <filename unknown>:0
at System.IO.File.ReadAllText (System.String path) [0x00000] in <filename unknown>:0
at CatalystHD.Shared.BaseLoginController.CheckIfFirstRunThisVersion () [0x00000] in <filename unknown>:0
at CatalystHD.Shared.BaseLoginController.ViewDidLoad () [0x00000] in <filename unknown>:0
at MonoTouch.UIKit.UIViewController.get_View () [0x00000] in <filename unknown>:0
at CatalystHD.IPad.RootViewController.AnimateTo (MonoTouch.UIKit.UIViewController aController, UIViewAnimationTransition transition) [0x00000] in <filename unknown>:0 …Run Code Online (Sandbox Code Playgroud) 我有下面的代码.
public static IEnumerable<PropertyInfo> GetAllPublicInstanceDeclaredOnlyProperties(this Type type)
{
var result =
from PropertyInfo pi in type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
select pi;
return result;
}
Run Code Online (Sandbox Code Playgroud)
我试图将其转换为PCL库,但我无法弄明白.我试过了
type.GetTypeInfo().DeclaredProperties.Where(x => x.BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
Run Code Online (Sandbox Code Playgroud)
但是BindingFlags不存在.
我错过了什么?
我有一个shell脚本startup.sh执行以下操作(创建一个RAM磁盘并启动teamcity代理):
#!/bin/bash
DISK=`/usr/bin/hdiutil attach -nobrowse -nomount ram://16777216`
/usr/sbin/diskutil erasevolume HFS+ "RamDiskCache" $DISK
/Users/administrator/buildAgent/bin/agent.sh start
Run Code Online (Sandbox Code Playgroud)
我可以通过键入命令行./startup.sh运行它,它运行正常.当我从launchd运行时,它只创建RAM磁盘,teamcity无法启动.
我的launchd plist位于〜/ Library/LaunchAgents
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.datafinch.teamcity</string>
<key>Program</key>
<string>/Users/administrator/startup.sh</string>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
编辑
这是agent.sh文件:
https://gist.github.com/chriskooken/19f5856e3ce3c2322c53cb0afa69b057
c# ×7
xamarin.ios ×3
.net ×2
ios ×2
reflection ×2
bash ×1
c++ ×1
encryption ×1
fractions ×1
iphone ×1
launchd ×1
mono ×1
objective-c ×1
pcl-crypto ×1
percentage ×1
range ×1
ruby ×1
teamcity ×1