xamarin - xamarin iOS 中的 MakeTextWritingDirectionRightToLeft(null)
问题描述
我正在尝试RightToLeft
在我的项目中实现方向。其他工作正常,但标签没有在 iOS 中向右移动,为此我创建了一个LabelRenderer
在其中传递此方法MakeTextWritingDirectionRightToLeft(null)
但出现异常的方法
Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[UILabel makeTextWritingDirectionRightToLeft:]: unrecognized selector sent to instance 0x7fd2fb68b680
谁能告诉我在这个函数的参数中传递什么而不是null?
解决方案
您可以尝试使用以下代码在我的项目中实现 RightToLeft 方向。
[assembly: ExportRenderer(typeof(Label), typeof(CustomLabel))]
public class CustomLabel: LabelRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
{
base.OnElementChanged(e);
Control.TextAlignment = UITextAlignment.Right;
}
}
推荐阅读
- android - Android Layout Inspector 中的灰色视图是什么意思?
- sql - 为什么添加 ORDER BY 会大大加快查询速度?
- java - 在“提升和转移”迁移中分析外部(联系)依赖关系的最佳方法是什么?
- perl - perl WWW::Mechanize 跟踪某个表行中的链接
- kotlin - 创建 n 元笛卡尔积的惯用方法(多组参数的组合)
- python - 为什么 else 语句总是运行
- angularjs - 在 web 和 AngularJS 1.5 中存储密码的最佳方式?
- algorithm - 找到具有负边缘且没有负循环的最短路径的算法
- amazon-web-services - 将行添加到文件的命令的 Cloud-init runcmd 语法
- javascript - 下载领英页面