我如何使用进度条和取消按钮实现自定义UIAlertview? [英] how i can implement a custom UIAlertview with a progress bar and a cancel button?

查看:164
本文介绍了我如何使用进度条和取消按钮实现自定义UIAlertview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨iPhone应用程序开发人员,

Hi iPhone application developers,

我正在开发一个iphone应用程序。
此应用程序允许用户将图像上传到我的服务器。
我想在alertView中显示上传进度。
我需要一些示例代码来说明如何使用进度条实现自定义UIAlertView。

I am developing an iphone application. This application allows a user to upload images to my server. I want to show the upload progress in an alertView. I need some example code to illustrate how to implement a custom UIAlertView with a progress bar.

提前致谢。

推荐答案

执行此操作的快速方法是使用UIAlertView并重新定位其内部子视图以将进度条推入其中。这样做的缺点是它很脆弱,很可能会在未来中断。

The "fast" way to do this is to take a UIAlertView and reposition its internal subviews to shove your progress bar into it. The downside of that is it is fragile and is likely to break in the future.

正确的方法是实现像你这样的UIWindow的子类想要将windowLevel设置为UIWindowLevelAlert,以便它在当前窗口前绘制。获得一些工作应该相当容易,但让它看起来像内置警报之一需要花费很多精力。

The correct way to do this requires implementing a subclass of UIWindow that is layed out like you want and set its windowLevel to UIWindowLevelAlert so that it draws in front of your current window. It should be fairly easy to get something working, but getting it to look like one of the builtin alerts will take a lot of effort.

在你做其中任何一个之前,我建议你重新考虑你的用户界面。为什么应用程序在上传时会阻止。为什么不在屏幕上的某个位置放置状态栏,让用户在异步上传时与应用程序保持交互。看一下消息应用程序在上传彩信时的工作方式,以获取我所谈论的一个例子。

Before you do either of those though, I would suggest you rethink your UI. Why should your application block while it is uploading. Why not just put a status bar somewhere on the screen and let the user keep interacting with the application while you do the upload in asynchronously. Take a look at how the Messages app works while it is uploading an MMS for an example of what I am talking about.

当应用程序阻止它们时,用户讨厌它正在进行中,特别是在没有多任务处理的iPhone上。

Users hate it when an application blocks them while something is going on, especially on the iPhone where there is no multitasking.

这篇关于我如何使用进度条和取消按钮实现自定义UIAlertview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆