How to take control of Dismissal of UIAlertView in iPhone - iphone

I need to know if I can decide in the action method of the Buttons of UIAlertView whether to dismiss the alertView or not. In short On click of certain buttons of AlertView, I dont want my alert view to dismiss.

There's no way that I know of to do this. But it sounds like you're using UIAlertView in a manner for which it's not really intended. What are you actually trying to accomplish?

I ended up adding my own custom button instead of using the ones provided by the AlertView. After assigning my own actions to this Buttons I was able to control the dismissal of the alertview from those actions.

Related

Is there a way to call an alertView from a tabBarItem

I am trying to implement a way for a user to logout of my app through a custom tabBarController. I have 5 tabBarItems, and I want the first one to be a logout tabBarItem - so when a user taps on it, an alertview pops up asking "are you sure you want to logout?". Is this possible - and if so what would be the best way about implementing this feature?
thanks!
-Matt
That seems like an unintuitive UI. I would consider redesigning so that there is a logout button somewhere within a view controller, toolbar or navigation bar.
With that said, if you really, really insist on making a "logout" tab bar item, you can create a UIViewController that presents a UIAlertView in viewDidAppear: and implements the UIAlertViewDelegate protocol. Then in alertView:clickedButtonAtIndex: you can update your global state to handle a logout (i.e. broadcast a notification through NSNotificationCenter, make a custom AppDelegate call, etc.).

How to alert and stop attempted segue if video is recording

I have a view that allows video recording via a start/stop button without a preview view, and I want to remind the user to stop recording if they attempt to change storyboard views (by touch gesture or by a flipside info button) while a video is recording. How can I prevent the segue to another view if an AVFoundation video capture session is active, and make a UIAlertView pop up that reminds the user to stop recording first. I put the UIAlertView in a viewWillDisappear and it pops up but I don't know how to make the popup conditional, or to stop the segue from proceeding. Thank you for any assistance and example code.
Two options:
Disable the button/gesture.
Instead of creating the segue from the button/gesture in IB, create it from the view controller. Then you can have the button/gesture's action method call performSegueWithIdentifier: following whatever validation logic you want.
Just disable the button/gesture or whatever that allows the view to be changed. (Make a visual change to it so that the user know that it is disabled). Or you can add a new handler for the button/gesture to display the alert.

Any way to prevent UIActionSheet from being dismissed when user clicks a button in it?

I added a UIProgressView to my UIActionSheet to indicate the download progress. So I do not want my UIActionSheet to be dismissed when user click the download button in it.
But is there a way to do that ?
Right now I implement didDismissWithButtonIndex delegate method to show UIActionSheet again after it was dismissed. But I was hoping there is a better way.
UIActionSheet is a modal view, which means that it blocks UI completely. Since blocking UI is considered a bad practice, preventing an action sheet from dismissing is not supported. Instead, you should make a completely separate progress indicator outside the action sheet.
#Yar, thanks for the answer, I will try your solution some other time.
But I am also satisfied with my current solution. UIActionSheet.h said
// Called when a button is clicked. **The view will be automatically dismissed after this call returns**
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex;
So I guess hit any buttons will always dismiss action sheet. Then my solution is first hide progress bar; when user hits download button, show action sheet again but hide the download button and show progress bar.
The cancel button is always there in case user wants to cancel download even after download is started.

how to disable user interaction of only main view with out subview

I did a simple view based application.
I need to place three textfields in an alert view.
it is not possible According to UI guidelines.
So that i crate a view just like an alert view,And place text field in them.
Add it as subview to mainview while tap on a button.
Now what i need is when ever tap on button i need to disable userinteraction to main view,and enable userinteraction to the subview.
For that i am trying this code on button click event.
[object.viewController.view setUserInteractionEnabled:NO];
here object is object of appdelegate class.
But,if i place this it disables userinteraction of subview also.
But i need to disable for only main view.
i think people get what my problem,
if not let me add a comment.
Thank u in advance.
You can add UITextField inside UIAlertView, so it will cover main view so (as you required) user could not interact with the main view.
Similar thread which discuss UITextField in UIAlertView on iPhone - how to make it responsive?
Here is You tube video to add UITextField inside UIAlertView
I hope it will resolve your problem.
i resolve my problem,instead of disable of user interaction of main views i disabling user interaction for contents in the view(Buttons,textfields...).
And enabling then when sub view while closing sub view.
Let me Know if there is any Better way than this.
try using an action sheet. they;re much more flexible. on second thought check out InputAlertView in this

add new window or view on the alertview click button in iphone

i juzz want to know that how we can add new window or view on the click of an alertview button in iphone?
I'm not sure you can do that from an AlertView since alertviews are meant only to display a specific alert not to take an action. I guess you better off using an ActionViews which is recommended by Apple if you want to perform a certain action from a model view in iphone.
Regards,