延迟navigationController弹出UITableView的detailView
如果对 UITextField 和 UISegmentedControl 进行了一些更改,我正在寻找一些有关保存类似确认的帮助。
我可以阻止 UINavigationController 弹出视图吗?然后根据 AlertView 中的按钮弹出?
我使用 UITextField 和 UISegmented 控件将数据 POST 到 Web 服务。
我也许需要为此使用 modalView ?但首先想看看是否有人有其他想法,因为如果可能的话,我想减少导航点击。
对此有何建议?
谢谢,
Im looking for some help regarding to put a save like confirmation if some changes where made to a UITextField and UISegmentedControl.
Can I prevent the UINavigationController from pop the view? And then pop based on buttons in a AlertView?
I use the UITextField and UISegmented control to POST data to a webservice.
I perhaps need to use a modalView for this? but wanted first to see if someone have another idea, because I would like to keep navigation clicks down if possible.
Any suggestions for this?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不只使用
UIAlertView
?编辑:再三考虑,并重新阅读您的问题+评论,我建议使用带有经典确定/取消按钮的模态视图+
UIAlertView
(s)确认。 (UIAlertView
在确定/取消时“弹出”很容易通过UIAlertViewDelegate
实现)这就是模态视图的用途,阻止 UI 直到某些用户操作已完成。就像一个表格。这就是我处理所有表单的方式,以及 Apple 的做法(只需查看创建邮件屏幕的示例,或任何形式的 iOS 应用程序)
添加“神奇” > 需要用户在导航控制器的后退按钮上进行交互的操作在用户体验方面很糟糕,如果您回击,您会期望视图弹出,仅此而已。如果 Apple SDK 甚至允许取消该事件,我会感到惊讶......
Why not just using a
UIAlertView
?EDIT: On second thought, and re-reading your question + comment, I would recommend to use a Modal View with classics OK/Cancel buttons + a
UIAlertView
(s) for confirmation(s). (UIAlertView
"poping" on OK/Cancel is easy to do viaUIAlertViewDelegate
)That's what Modal views are for, block UI until some user action has been completed. Like a form. This is how I do all my forms, and how Apple does (just look at the create mail screen for an example, or any form of iOS apps)
Adding a "Magical" action requiring user interaction on the back button of a navigation controller is bad in terms of user experience, if you hit back, you expect the view to pop, nothing else. I would then be surprised if Apple SDK even allows to cancel that event...
您可以做您想做的事情,而不需要模态视图。
首先,当字段内容被修改时,您可以使用文本字段的
UITextFieldDelegate
在控制器中设置一个标志。当数据发送出去时,您可以重置该标志。然后,您可以重写
UIViewContorller
的viewWillDisappear
来向用户显示警报,以防在视图即将消失时尚未发布新数据并给他将其发送到服务器的可能性。当您移动到导航 UI 中的不同控制器时,将调用此方法,并且您将没有机会“拒绝”该操作。You can do what you would like without the need of a modal view.
First, you can use your text field's
UITextFieldDelegate
to set a flag in your controller when the field content is modified. You can reset this flag when the data is sent out.Then you could override your
UIViewContorller
'sviewWillDisappear
to show an alert to the user in case new data have not been posted at the moment the view is going to disappear and give him the possibility of sending it to the server. This method will be called when you move to a different controller in your navigation UI, and you will not have a chance to "reject" the operation.