Every 10 min I synchronize my app with server, and when something wrong with server, I show UIAlertView.
NSString *alertTitle = #"Sync failed";
NSString *alertMessage = #"Something wrong with server"
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:alertTitle
message:alertMessage
delegate:nil
cancelButtonTitle:NSLocalizedString(#"OK", #"OK button title")
otherButtonTitles:nil];
[alertView show];
[alertView release];
If to shoot down server and do not touch phone, in hour there will be 6 Alert Dialogs, and I supposed to close 6 AlertDialogs. How to fix that ? Can AlertView check if its already shown to user or something like that ? Thanks...
Related
I'm having problem with my UIAlertView, Here is how I show it,
UIAlertView *message = [[UIAlertView alloc] initWithTitle:#"エラー"
message:#"Oneスロットに何も画像が設定されていません"
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[message show];
But then the preview looks like this:
What I wanted is to make it just 1 Line, but I have read in some thread/question that it shouldn't be done, what is the best way to do this without making my app being rejected? I Have read about changing its width, but is this allowed?
For the first time I am playing with APNS, I tried to run a proof of concept, with an iOS 5.0.1 device, and the didFailToRegisterForRemoteNotificationsWithError is fired. I know it has been fired because I show an UIAlertView to notify the error:
- (void)application:(UIApplication*)application
didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
// Inform the user that registration failed
NSString* failureMessage = #"There was an error while trying to \
register for push notifications.";
UIAlertView* failureAlert = [[UIAlertView alloc] initWithTitle:#"Error"
message:failureMessage
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[failureAlert show];
[failureAlert release];
}
How can I get more info about the error?
Try doing something like NSLog(#"%#", error.userInfo");, that should output some info into the terminal.
I ended up with this code, which works and lets me progress a bit:
NSString* failureMessage = error.localizedDescription;
UIAlertView* failureAlert = [[UIAlertView alloc] initWithTitle:#"Error"
message:failureMessage
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles:nil];
[failureAlert show];
Sorry, iObjectiveC noob here.
Is there any way of displaying a UIAlertView with Login/Password text fields, so that the keyboard type is of type UIKeyboardTypeEmailAddress?
I use a UIAlertView as follows:
var alertView = new UIAlertView("Login".Translate(), "", null, "Cancel".Translate(), "Login".Translate());
alertView.AlertViewStyle = UIAlertViewStyle.LoginAndPasswordInput;
or, in Objective-C:
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:#"Title"
message:#"Message"
delegate:self
cancelButtonTitle:#"Cancel"
otherButtonTitles:#"Login", nil];
[alertView setAlertViewStyle:UIAlertViewStyleLoginAndPasswordInput];
but all user names of my app are e-mail addresses, so I'd like to have the keyboard of the login textfield as an e-mail address keyboard, i.e. a UIKeyboardTypeEmailAddress.
Any ideas?
Got it. You can get the textfield of the UIAlertView and set the style there:
alertView.GetTextField(0).KeyboardType = UIKeyboardType.EmailAddress;
Obj-C:
[[alertView textFieldAtIndex:0] setKeyboardType:UIKeyboardTypeEmailAddress];
Looking for some help again...
I've currently got 2 sections of my app that need internet connection, 1 is a photo gallery through Flickr and the other a Twitter Feed, I was wondering if this is the correct code for the UIAlertView... I can get it working from a button but thats all!
{
-(void)didTap_roundedRectButton1:(id)sender forEvent:(UIEvent *)event {
UIAlertView *alertView = [[UIAlertView alloc] init];
alertView.title = #"You are not connected to the Internet!";
alertView.message = #"Please check your connection and try again...";
[alertView addButtonWithTitle:#"Ok"];
[alertView show];
[alertView release];
}
i think you need to use this example as i have used it to check is there any network is available and device is connected to any one of the network it is alos available on the apple's developer example site
example link is this
You should try this:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:#"You are not connected to the Internet!"
message:#"Please check your connection and try again..."
delegate:nil
cancelButtonTitle:#"OK"
otherButtonTitles: nil];
[alertView show];
[alertView release];
and can you post the code how do you create the UIButton?
When you first try to access a user's ALAssetsLibrary, the OS will present them with a dialog asking for permission. If they do not allow this, a failureBlock will be called and will always be called in the future. Is there a way to force a prompt of this authorization request again?
I notice in the Maps app, that they inform the user to go to the Settings app to turn on location services with a button. However, there is no way that I know of to programmatically open the Settings app. Should I just display directions as to how to turn on the location services?
You can't open up the settings app in an Apple approved manner.
The best you can hope for is to trap the error and then display a UIAlertView or other view with instructions on how to do this. Take a look at the latest v. of the Dropbox app for an idea on how they instruct the user.
When you try to access the Library from your code, you can use the error handler to catch the error and display an alert specifying to the user what to do.
Example
failureBlock:^(NSError *error) {
// error handling
if (error.code == ALAssetsLibraryAccessGloballyDeniedError) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error!"
message:#"Error loading image... \nEnable Location Services in 'Settings -> Location Services'."
delegate:self cancelButtonTitle:#"OK"
otherButtonTitles:nil, nil];
[alert show];
} else if (error.code == ALAssetsLibraryAccessUserDeniedError) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error!"
message:[NSString stringWithFormat:#"Error loading image... \nEnable Location Services in 'Settings -> Location Services' for %#.", [[[NSBundle mainBundle] infoDictionary] objectForKey:#"CFBundleDisplayName"]]
delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
} else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error!" message:#"Error loading image..." delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil, nil];
[alert show];
}
}