我有一个用MvvmCross设计的Xamarin项目.有子项目:
如果我将图像添加到我的iOS项目(Resoureces/Images/test_image.png),那么我可以使用以下代码加载它:
UIImage image = UIImage.FromBundle("Images/test_icon.png");
Run Code Online (Sandbox Code Playgroud)
现在,我想使用一个新的子项目
该库应该加载图像.我在Controls(Resoureces/Images/test_image.png)中添加了一个图像
但我无法在Controls proj中加载此图像.
我的问题:如何从iOS库加载图像?
public class MyButton : UIButton
{
public MyButton () : base()
{
Initialize ();
}
void Initialize()
{
// load image from bundle
UIImage image = UIImage.FromBundle("Images/test_icon.png");
// image is null
this.SetImage (image, UIControlState.Normal);
}
}
Run Code Online (Sandbox Code Playgroud)
而ViewController类是:
public partial class FirstView : MvxViewController
{
public FirstView () : base ("FirstView", null)
{
}
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// load image from …Run Code Online (Sandbox Code Playgroud) 我希望在呈现后立即解雇,但只能在2秒后才能解决.这该怎么做?
这是我在UILabel上从UITapGestureRecognizer调用的方法.
- (IBAction)labelTaped:(UITapGestureRecognizer *)sender {
if (sender.state == UIGestureRecognizerStateEnded) {
CGRect frame = CGRectNull;
NSString *message = nil;
// ...
// some code
/// ...
if (message) {
// show info alert
__weak __typeof(self)weakSelf = self;
UIAlertController* alert = [UIAlertController alertControllerWithTitle:nil
message:message
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction* cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString(@"alert_ok", @" - ")
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action) {
if ([weakSelf.dismissAlertTimer isValid]) {
[weakSelf.dismissAlertTimer invalidate];
}
}];
[alert addAction:cancelAction];
UIPopoverPresentationController *popoverController = alert.popoverPresentationController;
popoverController.sourceRect = frame;
popoverController.sourceView = sender.view;
[self.mainController presentViewController:alert animated:YES …Run Code Online (Sandbox Code Playgroud)