简体   繁体   English

为什么我的UIButton委托必须在视图中显示更改之前完全执行?

[英]Why does my UIButton delegate have to execute entirely before changes are shown in view?

I'm doing some MonoTouch development, and I really can't figure out an problem I've run into 我正在做一些MonoTouch开发,我真的无法弄清楚我遇到的问题

I'm having an ViewController containing a UIButton. 我有一个包含UIButton的ViewController。 I have added a delegate to the TouchDown event of this button. 我已将一个委托添加到此按钮的TouchDown事件中。 In this delegate I'm calling a WebService and trying to change the colour and title of the button. 在这个委托中,我正在调用WebService并尝试更改按钮的颜色和标题。 However nothing happens to the button before the entire delegate have been executed. 但是,在执行整个委托之前,按钮没有任何反应。 The thing is that the webservice is rather slow, so I want to give the users a waiting message by changing the colour and title of the button. 问题是web服务很慢,所以我想通过改变按钮的颜色和标题给用户一个等待的消息。

The code: 编码:

    public override void ViewDidLoad ()
    {

        View.BackgroundColor = UIColor.Black;

        bookButton = new UIButton( new RectangleF(10,100,this.View.Frame.Width-10 ,40) );

        bookButton.BackgroundColor = UIColor.Clear;
        setButton();

        bookButton.TouchDown += delegate {

            gymClass.book();
            setButton();
            tableView.ReloadData();
            NavigationController.PopViewControllerAnimated( true );

        };

        this.View.AddSubview( bookButton );

    }

Anyone, please? 有人吗?

委托在负责渲染的主线程上执行,因此您将阻止渲染器,直到您返回。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么UIButton具有3种不同的图像属性? - Why does a UIButton have 3 different image properties? 如何在NavigationController的视图内进行UIButton动作调用控制器委托? - How to have a UIButton action inside a NavigationController's view call the controllers delegate? Swift:我的代理协议方法需要在另一个视图控制器上执行 - Swift: My Delegate Protocol Methods Need to Execute on Another View Controller 为什么我的UIButton没有添加到viewForSectionHeader的自定义标题视图中 - Why is my UIButton not added to the custom header view of my viewForSectionHeader 为什么UIScrollView的自定义子视图会全部重绘,而不是部分重绘,以及如何更改它? - Why does a custom child view of a UIScrollView get redrawn entirely and not only partially and how to change this? UISearchDisplayController并不完全涵盖子视图控制器 - UISearchDisplayController does not entirely cover a child view controller 为什么我的应用程序委托中的 class 变量没有被实例化? - Why does my class variable in my Application Delegate not get instantiated? 为什么在-reloadData上未调用我的表视图委托方法? - Why are my table view delegate methods not being called on -reloadData? 推送视图控制器时,UIButton会更改大小 - UIButton changes size when pushing view controller Objective-C:UIButton图像不变 - Objective-C : UIButton image does not changes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM