Let the UIAccessibilityPostNotification complete in UIAlertView - ios

I want to announce a message through UIAccessibilityPostNotification in a UIAlertView. My problem is that the alert view closes and the message abruptly stops (at least that is my analysis), barely two words get spoken. Is there any way to let the notification complete? My code is as follows:
//Function which calls UIAlertView
-(IBAction)foo:(id)sender
{
UIAlertView* myAlert = [[UIAlertView alloc] initWithTitle:#"Select to get more information"
message:#""
delegate:self
cancelButtonTitle:#"Cancel"
otherButtonTitles:#"a",#"b",#"c", nil];
myAlert.tag=2;
[myAlert show];
//Code comes here immediately, even if I don't select anything on alertView.
NSLog(#"Does it come here? Yes!");
}
My AlertView:
if ([alertView tag]==2)
{
//Some code
NSString* message = #"Long message";
if (UIAccessibilityIsVoiceOverRunning())
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, message);
else
NSLog(#"Voice-over is not running.");
}
I am also ready to change my code logic. I tried if the code continues after we select a choice on alert view, so that I can make the message variable global and post the notification through the foo function. It doesn't happen as expected. Program stops after alertView closes.
Does any workaround exist? I am an amateur iOS programmer so a little code along with the explanation would help.
P.S. I can even use something other than alert view, if there is any. I just want to have a pop-up and some buttons as choices.

IMO, you should create your on Custom popup using UIView to display options to the end user. Then first display your popup that gives user the options, once user selected one of them (or tap a button after selecting one of them), call UIAlertView to show the relevant messages.
Hope this way your problem will be solved.

Related

How to position a UIAlertView

I've tried using this
message = [[UIAlertView alloc] initWithTitle:#"Incorrect!"
message:wrongString
delegate:self
cancelButtonTitle:#"Try Again"
otherButtonTitles:nil];
if(adjustIncorrect) {
NSLog(#"Showing adjusted");
message.transform = CGAffineTransformMakeTranslation( 0.00, 300.00);
}
[message show];
It is printing out Showing Adjusted, so I know that's not the issue. But the alert isn't moving no matter what numbers I put in. I've seen a few posts saying with the newer versions of iOs this might not work, any ideas?
Unfortunately you can't do it: "The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified.". You should not access any private properties in UIAlertView directly as well as you should not subclass UIAlertView - this is clearly stated by Apple and is likely to lead to a rejection of your App during revision when sent for publication to the Apple Store. The same applies to UIActionSheet.
Instead you should look into implementing your own alert view to be loaded modally when needed.

URL in Alert body

Can we put a tappable link in the alert body? Tapping the link should open the Mail client.
My pressing question is that has anyone tried it and is it accepted by apple.
The alert says 'Please contact Helpdesk for more information' with an OK button - tap on 'helpdesk' and it should open the mail client.
From the Apple Documentation in regards to UIAlertView Class Reference
Subclassing Notes
The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified.
So to get the sort of customization you are talking about you would have to subclass UIAlertView which is not allowed, your app will be rejected.
However there are some alternatives to UIAlertView implementations that can be found cocoa controls.
You could just have a button that does the same as the link and than you could just use this method
- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
To determine which button was pressed then run your mail client.
I think While these kind of adding customizations to a UIAlertView is strongly discouraged by Apple You can Use the UIAlertView delegate Function to detect which button is pressed and can reaction on as required.
UIAlertView *alert = [[UIAlertView alloc] init withWithTitle:#"Title" message:#"message" delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"Your Event you want fire", nil];
- (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch(index)
case 1:
//fire Your Event you want fire
break;
}
And if you looking some kind of change with UIAlertView One option will you cn create you own Custom AlertView try this link SO Questions

Popping System Alert on UISwitch's 'ON' state

I am new to this and this is my first question.
Would any one let me know whether we can or cannot pop a System Alert on UISwitch's 'ON' state.
I Know we can have custom alert but i don't want that.It is related to GPS whereby when the user switches on the switch it should give you an System Alert asking to on your GPS.
No, it's automatically displayed when the app accesses Core Location. If the user rejects it, it's displayed a second time at the next launch, then it keeps quiet and is not shown anymore.
So there is no way you could force this dialog to show again. iOS will ask the user again on the next start-up of the app.
Edit : If you need to show an alert for GPS you van check whether GPS is enabled or not as if userlocation is nil or not. if it is not nil then set your switch enabled else set disbled.
MKUserLocation *userLocation = mapView.userLocation;
if (!userLocation.location)
{
// Show an alert here to turn on Location service
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Location Service Disabled"
message:#"To re-enable, please go to Settings and turn on Location Service for this app."
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[alert show];
}
So user can enable GPS in settings directly.
Hope it helps you.

'wait_fences: failed to receive reply: 10004003' on loading UIAlertView (iOS)

I'm getting the 'wait_fences: failed to receive reply: 10004003' when I call a UIAlertView. It's called when the app first opens. It doesn't crash the app or seem to effect the functionality of it at all but I want to clean up my app completely. It's a tab bar app and I've entered the code in the viewDidLoad section of the View Controller that's first loading in the app:
- (void)viewDidLoad
{
[super viewDidLoad];
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:#"Welcome!" message:#"Thanks for downloading our new app! \n \n Take a look around and if you have any questions, don't hesitate to contact us." delegate:nil cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
I have seen other answers on the site to this error but they seem to deal with UITextFields and I'm not sure how they apply to my situation exactly. I apologize if I'm missing something simple, but I'm learning hands-on and can't seem to figure this one out. Thanks!
You should show it in -(void)viewDidAppear method. When view just loaded it is not on screen.

UIActionSheet cancelButtonTitle ipad

I'm using UIActionSheet to present a set of choices to the user. It works fine on iPhone and iPod Touch, but on the iPad the "cancel" option is always hidden. That is, the "dialog box" with the options appears, but the "cancel" button is missing.
Here's the code:
self.popupQuery = [[[UIActionSheet alloc] initWithTitle:title
delegate:self
cancelButtonTitle:cancelButtonTitle
destructiveButtonTitle:nil
otherButtonTitles:option0, option1, cancelButtonTitle, nil] autorelease];
The UIActionSheet docs state:
cancelButtonTitle:
The title of the cancel button. This button is added to the action sheet automatically and assigned an appropriate index, which is available from the cancelButtonIndex property. This button is displayed in black to indicate that it represents the cancel action. Specify nil if you do not want a cancel button or are presenting the action sheet on an iPad.
I'm not passing nil, so I'm not clear what's going on. Is this a bug?
It might depend on how you are presenting your UIActionSheet, but bear in mind that tapping outside the UIActionSheet is the cancel button on the iPad.
While there may be an alternative way to present the UIActionSheet, the default will leave you with out that cancel button.
EDIT:
According to another answer on a very similar question, you can make the cancel button appear on iOS 4.2 and prior by using the following code. Note that in iOS 4.2.1, this seems to have been changed and will no longer work.
actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
or this:
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;

Resources