What's the proper behavior for deleting an iPhone table row with an asynchronous server call?
I'm working on adding the functionality to delete a row in a UITableView on the iPhone. It's pretty clear how to delete the row within the application, from both the model and the UI. However, the deletion requires a call to be made to the server, which can't be guarant开发者_StackOverflow中文版eed to succeed given all the funkiness that can happen with mobile connectivity. I'm implementing both swipe-to-delete for single rows and switching the entire table into editing mode.
- What kind of behavior can be used within the UITableView/UITableViewCell to indicate a server call in progress? I think this can be tricky with the limited real estate.
- Should the user be permitted to delete other rows while a delete call is in progress?
- What behavior is recommended for errors? Displaying a UIAlertView?
- Change the accessory view of the cell to a
UIProgressView
to show that some activity is taken place and set thenetworkActivityIndicatorVisible
. - Since all UI interaction happens on the main thread you could allow the user to delete multiple rows at the same time. Just send the request in the background and dont allow that user to swipe and delete that row until the operation is complete.
- For a quick and dirty solution a
UIAlertView
would work. A more elegant solution would be some sort of view that drops down from the status bar with details or maybe add a button to the cell that when the user clicks on it gives them a reason why it fails. There are several solutions here.
精彩评论