URL in Alert body - ios

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

Related

Alert message not rotating in IOS8

I am building an iPhone app which shows an alert message when a particular button is tapped. Auto-rotaion is in ON state. When i rotate my phone the whole app view as well as the alert message rotates in iOS7 But, in iOS8 views are rotated except alert message`
UIAlertView does not work properly in iOS8 The, iOS8 uses a new UIAlertController The given linked worked for my case.
Reference Link
This is happening because the iOS not able to understand the multiple operation at a time .You can call the UIalertview with delay like .I have same issue with iOS8 this code is working fine for me.
[self performSelector:#selector(showAlert) withObject:nil afterDelay:0.5];
-(void)showAlert
{
UIAlertView *alert=[[UIAlertView alloc]initWithTitle:#"Your alert Title." message:#"Your alert Message." delegate:nil cancelButtonTitle:#"Ok" otherButtonTitles:nil, nil];
[alert show];
}

Let the UIAccessibilityPostNotification complete in UIAlertView

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.

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.

How to show alert view when tab bar item is pressed and how to ignore it when used in a other target?

I have a UITabBar project with 5 tabs.
I am making 2 targets versions out of it: Free and a Paid version.
In the free version, when a user tries to navigate to tab item index 3 or 4, a UIAlertView should appear with a basic message like:
Do you want to upgrade?
YES / Cancel
When pressing Cancel button, the view should go to first view controller.
How should I do that?
Also, my next question, (I am aware that I should make another question here in Stack though) is how to prevent the UIAlertView from showing up in the paid version?
I have come as far as to use a button for UIAlertView for tab item 3 & 4 , but I don't want that.
The 2 targets are functioning well and I use the following code:
- (IBAction)openAlert:(id)sender
{
#ifdef FREE
UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:#"Attention"
message:#"Choose option"
delegate:self
cancelButtonTitle:#"Cancel"
otherButtonTitles:#"Download Full version", nil];
[alertView show];
#endif
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex ==1) {
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:[NSString stringWithFormat:#"http://***.com"]]];
}
}
Any help would be appreciated.
On the cancel, to move to another UIViewController, you simply change the self.tabBarController object's setSelectedIndex
example:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (buttonIndex) {
case 0:
//Cancel button was clicked
[self.tabBarController setSelectedIndex:0];
break;
case 1:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:#"http://***.com"]]];
break;
}
}
As for the Free vs Paid, it's opinion-based.
One way which is basic is by using NSUserDefaults to remember whether the app is free version or paid version and handle your logic accordingly.
Set your appdelegate as the delegate of your tabbar controller and do this work in appdelegate or whereever
When the user press the cancel button then call
[yourTabbarController setSelectedIndex:0]
Write your code in the following delegate method to avoid alert in particular version(Paid/Free)
(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
For the first question, you need to make use of the value of the index of button clicked in the alert view inside (void)alertView: (UIAlertView )alertView clickedButtonAtIndex:(NSInteger)buttonIndex and check if the index of the button pressed is same as the index of the cancel button. Then you can programatically press the tab for the required view and go to that.
Before you load the alert pop up, check for the status of the app, paid or free. You can check the same in two ways, one is by storing the app purchase status on the device in NSUserDefaults, and other by means of a server authentication, though the server authentication would be a hinderance in the use of the app as it would take some time to get the response from the server and in case of no network connectivity, the user would not be able to use the paid features of the app.
In case the app is having the required paid status, simply let the view in the paid tab load else just display a black screen.
You can implement this check in the view controllers of the paid tabs. In viewWillAppear, implement this check for getting the payment status and then if the app is not a paid one, show a black view and present the alert message. Else if the app is paid, business goes as usual.

'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.

Resources