UIAlertView from Tab Button - No Internet Connection - iphone

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?

Related

UIAlertView message

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?

didFailToRegisterForRemoteNotificationsWithError is fired, how to get more info?

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.

Reachability Xcode iOS5

i want to add a alter if the user is not connected to the internet and clicks on a webview link.
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"Can't connect. Please check your internet Connection" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
Problem is here:
Void (-) gives error:(!)Invalid argument type 'void' to unary expression
Very possibly the problem does not lie with the -(void)webView:didFailLoadWithError method itself; rather, it seems you are using it in an incorrect way, i.e.. within an expression that requires a unary operator (e.g., negation, increment, etc.).
In other words, it seems you are trying to use the method's return value somewhere, but there is no return value from that method.
Check the code where you call -(void)webView:didFailLoadWithError...
This is very simple you dont have to code in any delegate method for check weather the user is connected to internet,for example the there is a login page for you and the user logs in but network is not connectd ,so we have to give an alert to user that the network is not connectd right?just simply add the
if(responce == nil)ie,responce from the url
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Error" message:#"Can't connect. Please check your internet Connection" delegate:self cancelButtonTitle:#"OK" otherButtonTitles:nil];
[alert show];
[alert release];
} else you code

iPhone: UIAlertView overlap

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

ALAssetsLibrary ALAssetsLibraryAccessUserDeniedError

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];
}
}