我目前正在阅读Xamarin.Forms简介中的导航部分.人们应该使用这种方法.但是应该如何使用呢?GetMainPage()
app delegate的默认实现如下所示:
申请代表:
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init ();
LoadApplication (new App ());
return base.FinishedLaunching (app, options);
}
}
Run Code Online (Sandbox Code Playgroud)
应用程序:
public class App : Application
{
public App ()
{
MainPage = GetMainPage ();
}
public static Page GetMainPage()
{
var mainNav = new NavigationPage(new ListExample());
return mainNav;
}
}
Run Code Online (Sandbox Code Playgroud)
我让它设法使用该GetMainPage()方法而不是获取
应用程序窗口应在应用程序启动结束时具有根视图控制器
如果我查看(旧的?)示例(example1,example2),app委托是不同的,并且CreateViewController()方法可用.在我的情况下,它不是!
将根页面加载到堆栈的正确方法是什么?
有谁知道如何使用Xamarin 获取iOS 8中的tmp目录路径?
配置Hyper-V并设法使其运行后,Android的Visual Studio模拟器正在启动.我可以看到我的启动画面,但随后该应用程序退出.这是输出日志:
InspectorDebugSession(1): StateChange: Start -> EntryPointBreakpointRegistered
InspectorDebugSession(1): Constructed
Android application is debugging.
03-25 10:24:48.717 D/dalvikvm( 1251): Late-enabling CheckJNI
03-25 10:24:48.749 D/dalvikvm( 1251): Trying to load lib /data/app-lib/MyApp.Droid-1/libmonodroid.so 0xa8f89c78
03-25 10:24:48.749 D/dalvikvm( 1251): Added shared lib /data/app-lib/MyApp.Droid-1/libmonodroid.so 0xa8f89c78
03-25 10:24:48.761 W/monodroid( 1251): Using override path: /data/data/MyApp.Droid/files/.__override__
03-25 10:24:48.761 W/monodroid( 1251): Using override path: /storage/emulated/0/Android/data/MyApp.Droid/files/.__override__
03-25 10:24:48.761 W/monodroid( 1251): Trying to load sgen from: /data/data/MyApp.Droid/files/.__override__/libmonosgen-2.0.so
03-25 10:24:48.761 W/monodroid( 1251): Trying to load sgen from: /storage/emulated/0/Android/data/MyApp.Droid/files/.__override__/libmonosgen-2.0.so …Run Code Online (Sandbox Code Playgroud) android android-emulator xamarin visual-studio-2015 visual-studio-emulator
是NSTemporaryDirectory()可用于Xamarin.iOS?我在Xamarin API中找不到任何东西.它与描述的目录有什么关系?
如果我在UWP设备上运行我的应用程序,我会在Output窗口中收到以下警告:
MakePRI:警告0xdef00522:为语言'en,de'找到的资源,但找不到默认语言的资源:'de-DE,en-US'.使用默认语言更改默认语言或限定资源.http://go.microsoft.com/fwlink/?LinkId=231899
不知道这是否相关,但我也知道
1> C:\ Program Files(x86)\ MSBuild\Microsoft\VisualStudio\v14.0\AppxPackage\Microsoft.AppXPackage.Targets(2459,5):警告:APPX4001:构建属性AppxBundlePlatforms未明确设置并基于计算目前正在建筑.使用"创建应用程序包"向导或编辑项目文件进行设置.
这个页面说明我有语言特定的资源,我没有用语言标签限定.我怎样才能知道这些资源是哪些资源?
我在Assets文件夹中有图像,但它们与语言无关.此外,我在Package.appxmanifestto中设置了默认语言de-DE.如果我从警告中搜索语言缩写,我只能在输出文件夹中找到一个priconfig.xml和.AppxManifest.xmlDebug
我该怎么做才能删除此警告?
编辑:
如果我添加一个AppResources.en-US.resx文件(目前我已将其en-US设置为默认语言Package.appxmanifest),警告似乎消失了.另外,我有一个AppResources.de.resx和AppResources.resx(应该en)的文件.但是为什么示例项目不需要这样的文件,尽管应该有相同的设置?我错过了什么?
我有一个ListView关于它的观点.现在,我切换到自定义渲染这个ListView(并为自定义呈现ViewCellBTW).如果我在模拟器(iOS,Android)中启动应用程序,我会收到以下异常:
Xamarin.Forms.Xaml.XamlParseException:位置12:13.无法分配属性"CachingStrategy":属性不存在,或者不可分配,或者值和属性之间的类型不匹配
如果我删除CachingStrategy一切似乎工作正常.这是我的代码:
查看,ListView放置在哪里:
<StackLayout xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MyApp.Views.SomeView"
xmlns:customViews="clr-namespace:MyApp.Views;assembly=MyApp"
xmlns:renderer="clr-namespace:MyApp.CustomRenderers;assembly=MyApp"
VerticalOptions="FillAndExpand">
<renderer:CustomListView x:Name="SomeList"
SeparatorColor="{StaticResource PrimaryLight}"
HasUnevenRows="True"
CachingStrategy="RecycleElement"
IsGroupingEnabled="True"
GroupDisplayBinding="{Binding Key}"
IsPullToRefreshEnabled="True"
RefreshCommand="{Binding LoadDocumentsCommand}"
IsRefreshing="{Binding IsBusy, Mode=OneWay}">
<ListView.GroupHeaderTemplate>
<DataTemplate>
<customViews:GroupingHeader/>
</DataTemplate>
</ListView.GroupHeaderTemplate>
<ListView.ItemTemplate>
<DataTemplate>
<customViews:MyListItem Clicked="Item_Clicked"/>
</DataTemplate>
</ListView.ItemTemplate>
</renderer:CustomListView>
</StackLayout>
Run Code Online (Sandbox Code Playgroud)
CustomListView
namespace MyApp.CustomRenderers
{
public class CustomListView : ListView
{
}
}
Run Code Online (Sandbox Code Playgroud)
CustomListViewRenderer
[assembly: ExportRenderer(typeof(MyApp.CustomRenderers.CustomListView), typeof(MyApp.iOS.CustomRenderers.CustomListViewRenderer))]
namespace MyApp.iOS.CustomRenderers
{
public class CustomListViewRenderer : ListViewRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<ListView> …Run Code Online (Sandbox Code Playgroud) 在文档中明确指出您需要为所有平台实现:
您必须在每个平台项目中提供一个实现。如果没有注册接口实现,则将
DependencyService无法Get<T>()在运行时解析该方法。
我没有提供实现,所以应用程序崩溃了。但是如果我不需要该平台的实现,我该怎么办?提供这样的无体方法?
public void HideKeyboard()
{
// We need an implementation for the DependencyService, even it is empty.
}
Run Code Online (Sandbox Code Playgroud)
我应该提供一个实现吗?
public void HideKeyboard()
{
try
{
InputPane myInputPane = InputPane.GetForCurrentView();
myInputPane.TryHide();
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
Run Code Online (Sandbox Code Playgroud)
还是DependencyService这里使用了错误的选项?
目前我正在与之合作PIDinRootline.这很好用.
[PIDinRootline=8,9]
//do something
[end]
[PIDinRootline=6,7,11]
//do something
[end]
Run Code Online (Sandbox Code Playgroud)
现在我想要解决7下的一组子页面.目前,父节点具有id 7的所有页面具有相同的代码.但现在我想在页面ID 128及其所有子页面上找到不同的东西.它是否允许制作类似的东西
[PIDinRootline=8,9]
//do something
[end]
[PIDinRootline=6,7,11]
//do something different
[end]
[PIDinRootline=128]
//do something
[end]
Run Code Online (Sandbox Code Playgroud)
因此页面128低于7.设置被覆盖,因为首先发生PIDinRootline = 7的设置,然后PIDinRootline = 128的设置.这是允许的吗?
我想在调试器中输入以下命令
po [[UIWindow keyWindow] _autolayoutTrace]
Run Code Online (Sandbox Code Playgroud)
我怎么在Xamarin工作室那样做?
编辑:
我看到了这个Objective-C代码
NSLog(@"%@", [[UIWindow keyWindow] _autolayoutTrace]);
Run Code Online (Sandbox Code Playgroud)
// for debugging auto layout.
@interface UIWindow (AutoLayoutDebug)
+(UIWindow *)keyWindow;
-(NSString *)_autolayoutTrace;
@end
Run Code Online (Sandbox Code Playgroud)
我想知道在Xamarin iOS中如何做到这一点?
我想使用CancellationToken中止文件下载.这是我试过的:
public async Task retrieveDocument(Document document)
{
// do some preparation work first before retrieving the document (not shown here)
if (cancelToken == null)
{
cancelToken = new CancellationTokenSource();
try
{
Document documentResult = await webservice.GetDocumentAsync(document.Id, cancelToken.Token);
// do some other stuff (checks ...)
}
catch (OperationCanceledException)
{
Console.WriteLine("abort download");
}
finally
{
cancelToken = null;
}
}
else
{
cancelToken.Cancel();
cancelToken = null;
}
}
public async Task<Document> GetDocumentAsync(string documentId, CancellationToken cancelToken)
{
Document documentResult = new …Run Code Online (Sandbox Code Playgroud) xamarin ×7
c# ×5
xamarin.ios ×4
ios ×3
android ×1
async-await ×1
autolayout ×1
ios8 ×1
listview ×1
localization ×1
select ×1
tmp ×1
typo3 ×1
typoscript ×1
uwp ×1