当我从大小函数内部调用Greet时,DisplayAlert会按预期显示警告但是当在事件之后从委托调用它时,它将使用正确的名称(Greet Has Called)记录到输出但DisplayAlert不显示.
public class CustomPage : ContentPage
{
...
protected override void OnValidSizeAllocated(double width, double height)
{
...
Greet("Test");
app.FB.GetName();
app.FB.NameRecieved += (s,e) =>
{
Greet(e.Name);
};
}
public void Greet(string name)
{
Utils.Log("Hey " + name);
DisplayAlert("Hey " + name, "Welcome", "OK");
}
}
Run Code Online (Sandbox Code Playgroud)
上面的代码输出"嘿测试",然后出现一个警告,说"嘿测试,欢迎",然后输出"嘿Leo"(这是正确的,因为这是来自Facebook帐户的名称)然后没有警报显示.
我正在尝试使用移相器和打字稿制作游戏。我按照这里的说明进行操作,它最初有效。当我尝试使用 AMD 和 requirejs 模块化我的代码时出现了问题
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Resonate</title>
<link rel="stylesheet" href="app.css" type="text/css" />
<script src="phaser.js"></script>
<script src="http://requirejs.org/docs/release/2.1.20/minified/require.js" data-main="app"></script>
</head>
<body>
<h1>RESONATE</h1>
<div id="content"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
export class Player {
color: string;
constructor() {
this.color = "#0000ff";
}
}
Run Code Online (Sandbox Code Playgroud)
import player = require("Player");
class PhaserDemo {
game: Phaser.Game;
constructor() {
this.game = new Phaser.Game(800, 600, Phaser.WEBGL, 'content', { preload: this.preload, create: this.create });
}
preload() {
this.game.load.image('phaser_run', 'run.png');
}
create() …Run Code Online (Sandbox Code Playgroud) 我正在制作一个带有Ionic的应用程序,我想要一个方形图像作为背景.需要根据不同的分辨率缩放图像; 我希望它能够填充设备的宽度,然后在保持宽高比的同时保持高度.
我已经尝试添加一个指令,以便计算正确的高度来设置,但我不能让它做任何事情,它似乎根本没有被调用.
<ion-view view-title="Home" >
<ion-content class >
<div id = "card" ng-model = "card">
<h3>{{card.name}}</h3>
</div>
</ion-content>
</ion-view>
Run Code Online (Sandbox Code Playgroud)
#card{
background-image: url("/img/education.png");
background-size: 100% 100%;
width : 100%;
}
Run Code Online (Sandbox Code Playgroud)
.directive("card", function($scope) {
console.log("Card directive called.");
return {
restrict: "E",
link: function (scope, element) {
console.log("Link Called");
element.height = element.width;
}
}
})
Run Code Online (Sandbox Code Playgroud) 我正在尝试实现一个界面,其中有五个页面可以在其间滑动和拖动,但您也可以通过点击底部的选项卡栏来更改页面.
我正在为CarouselPage编写自定义渲染器,但我无法在底部添加标签栏,因为iOS UITabBar需要和UIViewControllers数组之间切换,我只能访问这些页面.
这是我到目前为止所尝试的:
[assembly: ExportRenderer (typeof (ExtendedCarouselPage), typeof (ExtendedCarouselPageRenderer))]
namespace CustomRenderer.iOS
{
public class ExtendedCarouselPageRenderer : CarouselPageRenderer
{
protected UITabBar tabBar;
protected override void OnElementChanged (VisualElementChangedEventArgs e)
{
base.OnElementChanged (e);
tabBar = new UITabBar (new CGRect (0, this.View.Frame.Height * 0.9, this.View.Frame.Width, this.View.Frame.Height * 0.1));
tabBar.Items = new UITabBarItem[]{
new UITabBarItem("Hello",UIImage.FromFile("Homeicon.png"),UIImage.FromFile("HomeiconBlue.png")),
new UITabBarItem("World", UIImage.FromFile("Homeicon.png"),UIImage.FromFile("HomeiconBlue.png"))
};
tabBar.Bounds = new CGRect (0, this.View.Frame.Height * 0.9, this.View.Frame.Width, this.View.Frame.Height * 0.1);
tabBar.Frame = new CGRect (0, this.View.Frame.Height * 0.9, this.View.Frame.Width, this.View.Frame.Height * 0.1);
this.NativeView.AddSubview(tabBar); …Run Code Online (Sandbox Code Playgroud) 这是我当前用于加载图像的代码:
System.Uri uri;
System.Uri.TryCreate (imageURI, UriKind.Absolute, out uri);
_companyImage.Source = ImageSource.FromUri (uri);
Run Code Online (Sandbox Code Playgroud)
问题在于整个程序必须等待此任务完成,我想异步加载图像,但无法解决如何异步创建图像源的问题。
我有一个有很多静态方法的类,我将它用作一种样式表.
你给它的一个方法一个Label,它设置了一堆标签属性,如颜色,字体系列和字体大小.
我想创建一个页面,您可以在其中查看所有不同的Label样式,因此我想枚举这些静态方法,以便将每个方法应用于标签.
这可能吗?模板对象属性有更好的方法吗?
public static class Palette
{
public static class LabelStyle
{
public static void H3 (ref Label label)
{
label.TextColor = Xamarin.Forms.Color.White;
label.FontFamily = "Myriad";
label.FontSize = 14;
}
public static void H4 (ref Label label)
{
if (Device.OS == TargetPlatform.iOS)
{
label.FontFamily = Device.OnPlatform ("Myriad Pro", null, null);
}
else
{
label.FontFamily = "Myriad";
}
label.TextColor = Color.BlueBlack;
label.FontSize = 14;
}
...
}
...
}
Run Code Online (Sandbox Code Playgroud) c# ×3
xamarin ×3
ios ×2
javascript ×2
mobile ×2
.net ×1
android ×1
angularjs ×1
asynchronous ×1
css ×1
delegates ×1
ienumerable ×1
ionic ×1
js-amd ×1
navigation ×1
requirejs ×1
static ×1
typescript ×1
xamarin.ios ×1