【问题标题】:Scroll VIew and MBProgressHUD滚动视图和 MBProgressHUD
【发布时间】:2011-07-11 12:21:24
【问题描述】:

我是 iphone 开发新手。我在这里所做的是,加载一个带有滚动视图的视图,我在该视图上显示图片。 我在应用程序中有一个基本的导航控制器.. 现在,在图片加载过程中,如果图片没有完全加载,我想添加一个 MBProgressHUD .. 我为此使用以下代码,但无法在滚动视图的前面看到它,尽管在视图上添加了 hud,因为我无法移动滚动视图..

HUD = [[MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES] retain];
[[self.view superview] bringSubviewToFront:self.navigationController.view];

任何建议请...感谢您的帮助..

【问题讨论】:

  • 是的,HUd 是图像。

标签: ios uiscrollview uinavigationcontroller hud


【解决方案1】:

假设你这样做:

HUD = [[MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES] retain];

你得到一个UIImageView,你可以这样做:

[scrolView.view addSubView HUD.view];
HUD.frame=CGRectMake(x,y,width,height) //So you can specify where you want your image.

【讨论】:

    【解决方案2】:

    基于RuiAAPeres 的回答,这里有一些更完整的 Swift 代码:

    let frameHeight = self.tableView.frame.size.height
    let frameWidth = self.tableView.frame.size.width
    let hudHolderYCoord = frameHeight / 4 + self.tableView.contentOffset.y
    let hudHolder = HUDHolderView(frame: CGRectMake(0, hudHolderYCoord, frameWidth, frameHeight / 2))
    hudHolder.backgroundColor = UIColor.clearColor()
    self.view.addSubview(hudHolder)
    let hud = MBProgressHUD.showHUDAddedTo(hudHolder, animated:true)
    let label = "Just a sec.."
    hud.labelText = label
    

    【讨论】:

      【解决方案3】:

      无论是scrollview还是tableview,都可以参考以下链接

      MBProgressHUD at center added to tableView or scrollView

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-06-17
        • 1970-01-01
        • 1970-01-01
        • 2021-03-24
        相关资源
        最近更新 更多