我已经实现了导航抽屉,它工作正常.当导航器关闭时,我必须使所选项目取消选择的唯一问题.我想知道如何才能获得所选菜单项的索引值.
navigationView.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
menuItem.setChecked(false);
}
)}
Run Code Online (Sandbox Code Playgroud) 我从github https://github.com/xamarin/xamarin-forms-samples下载了Xamarin.Form示例项目
一旦我打开任何示例项目,它就不允许我在iOS模拟器上运行.
有没有人知道如何处理这个问题.我在Mac操作系统上使用Xamarin Studio.



更新1:
我还发现了以下有关我的问题的有用文章http://crossplatform.io/2013/12/02/setting-the-active-configuration-in-xamarin-studio/
我选择了TabbedPageDemo.iOS--> iOS|Debug然后我能够看到iOS部分,但它仍然没有给我选择Set As Start Project


在ViewModel,我有Save检查isValid属性的方法.
如果isValid是false,那么我想显示一条错误消息.
由于AlertDialog是特定于平台,我想知道你如何处理这种情况ViewModel?
public void Save()
{
if (isValid)
{
OnExit(this, null);
}
else
{
//issue an alert dialog here
}
}
Run Code Online (Sandbox Code Playgroud)
更新
我使用了以下插件并添加了以下代码行,如下所示,但它会引发错误.
else
{
Mvx.Resolve<IUserInteraction>().Alert("it is not valid");
}
Run Code Online (Sandbox Code Playgroud)
更新2
Chance.MvvmCross.Plugins.UserInteraction 是命名空间,但它用作类型错误.
更新3
我添加了Acr.UserDialogs插件并调用如下,但我有同样的错误.
Mvx.Resolve<IUserDialogs>().Alert("it is not valid");
Run Code Online (Sandbox Code Playgroud)
我Xamarin.Android最近一直在努力.我需要使用pdf生成器通过电子邮件发送报告.
我遇到过以下博客.我真的不知道要放什么FileStream fs = new FileStream (???????);.除此之外,我想在屏幕上打开或看到pdf.
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using System.IO;
using XamiTextSharpLGPL;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp;
namespace PDFAapp
{
[Activity (Label = "PDFAapp", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
int count = 1;
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
// Set our view from the "main" layout resource
SetContentView (Resource.Layout.Main); …Run Code Online (Sandbox Code Playgroud) 我以这种方式向地图添加注释:
MyAnnotation *annotationPoint2 = [[MyAnnotation alloc] init];
annotationPoint2.coordinate = anyLocation;
annotationPoint2.title = [NSString stringWithFormat:@"%@", obj];
annotationPoint2.subtitle = @""; //or set to nil
annotationPoint2.keyValue = [NSString stringWithFormat:@"%@", key];
[mapPins addAnnotation:annotationPoint2];
Run Code Online (Sandbox Code Playgroud)
针脚都是红色的,我希望它们都是绿色的.我怎样才能改变颜色?我尝试了以下内容,但仍然给出了红色标记:
annotationPoint2.pinColor = MKPinAnnotationColorGreen;
Run Code Online (Sandbox Code Playgroud) 我正在努力整合苹果公司的工资braintree.我已按照以下说明在脑树中启用苹果支付.在第一步中,如果单击证书签名请求,它将下载braintree_app_pay.certSigningRequest苹果成员资格中使用的文件.
我试图获取视图的屏幕截图如下.我正在获取Bitmap,我需要将其转换为Image以添加到PDF生成器中.
using (var screenshot = Bitmap.CreateBitmap(200, 100,Bitmap.Config.Argb8888))
{
var canvas = new Canvas(screenshot);
rootView.Draw(canvas);
using (var screenshotOutputStream = new FileStream(screenshotPath,System.IO.FileMode.Create))
{
screenshot.Compress(Android.Graphics.Bitmap.CompressFormat.Png, 90, screenshotOutputStream);
screenshotOutputStream.Flush();
screenshotOutputStream.Close();
}
}
Run Code Online (Sandbox Code Playgroud)
我的问题是如何转换Android.Graphics.Bitmap -->screenshot为Image?
我想用来自BitMap的Image本身替换url.
String imageUrl = "myURL";
Image image = Image.GetInstance (new Uri (imageUrl));
document.Add(image);
Run Code Online (Sandbox Code Playgroud) 我在IB中设置了一个按钮.我设置了一个IBOutlet,并将屏幕上的对象链接到它.有没有办法以编程方式更改按钮的位置和/或大小?我知道你可以改变标题和一些东西,但我不知道如何改变它的位置或大小.

现在我想相应地改变它的位置.可能吗?如果是,请告诉我如何,因为我试图在以下代码中更改我的按钮的位置,但它在头文件中不起作用.
@property (nonatomic, strong) IBOutlet UIButton *mybuttonOutlet;
Run Code Online (Sandbox Code Playgroud)
在实现文件中:
-(void)viewDidLoad {
screenSizeHeight=[UIScreen mainScreen].bounds.size.height;
if(screenSizeHeight==568)
mybuttonOutlet.frame= CGRect(38, 464 ,157,25);
if(screenSizeHeight==480)
mybuttonOutlet.frame= CGRect(38, 364 ,157,25);
}
Run Code Online (Sandbox Code Playgroud) 有没有以任何方式Xcode 8或8.1做Swift 2.X -> Swift 3迁移的单个文件中的一个项目,包括已经转换为斯威夫特3?
对于技术债务/遗留构建流程的原因,我们目前不得不维护项目的两个版本Xcode 7和Xcode 8版本.当我们必须将新的开发合并到Xcode 7以上时,这会引起麻烦Xcode 8.由于该项目已经完全转换到Swift 3我们的Xcode 8分支机构(包括大量的手动修复),我们无法使用全项目自动化转换器.因此,我们目前必须从做手转换Swift 2.2到Swift 3任何新的Swift这是在添加的文件Xcode 7,这需要时间显著量.
如果已经提出这个问题,我很抱歉,我找不到谷歌的任何明确答案.
因此,有一种方法可以监控CBCentralManagervia的状态变化centralManagerDidUpdateState().但有没有类似的方法调用监视状态更改CBPeripheral?我在CoreBluetooth库中找不到任何暴露的东西,我想在每次CBPeripheralState更改时调用一个函数.
现在我只有一个switch语句来检查外设状态,但它总是只返回连接或断开连接.我如何进入连接/断开连接的情况?我已经尝试将我的switch语句放在我的代码的各个部分,从bleInit()方法到startScanning(), connectToPeripheral()等等
switch(peripheral.state){
case .disconnected:
print("disconnected")
case .connecting:
print("connecting")
case .connected:
print("connected")
case .disconnecting:
print("disconnecting")
default: break
}
Run Code Online (Sandbox Code Playgroud)