简体   繁体   中英

How to make UIActivityIndicator show on top of UIImageView embedded in UIScrollView?

I have an imageView that is embedded inside of a scrollView so as to allow me to pinch and zoom the image in the imageView. I would like however to add an activity indicator to be spinning while the array of images is being loaded.

I put the indicator where I need it in IB, then hooked it up via an IBOutlet. It is spinning when the view loads, and stops at the correct time, the only problem is that it is behind the image and scroll views, not on top where I need it to be.

What can I do to change this and send the indicator to the front? I tried sending to back in IB as well as sending to front, neither have worked...

这是正确的吗?

I would recommend not putting it inside the UIScrollView. Just sit it on top of the UIScrollView visually, but make the root UIView as its parent. You can drag it around in the Document Viewer (hit Cmd-0) and drag it so that the activity indicator is listed as the same level as the other children of the root UIView. The things at the top of the list are in the "back" so make sure the activity indicator is listed below (but not inside) the UIScrollView.

I experienced a similar problem with Apple's PageControl example. ( http://developer.apple.com/library/ios/samplecode/PageControl/PageControl.zip ) For me the solution was to remove the overridden view method in the example, then the z-ordering should work as normal.

- (UIView *)view
{
    return self.scrollView;
}

Obviously this will only work if your code doesn't depend on it!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM