Обычно Apple предлагает для этого UIAlertView. Примеры в Центре разработчиков обычно имеют UIAlertViews просто потому, что Apple считает недостаточную доступность сети в приложениях, требующих сети, достаточно важной вещью, чтобы предупредить пользователя.
Я использую следующее (конечно, сохраняя авторские права)
в UIAlertView+Helper.h
:
//
// UIAlertViewHelper.h
// CocoaHelpers
//
// Created by Shaun Harrison on 10/16/08.
// Copyright 2008 enormego. All rights reserved.
//
#import <UIKit/UIKit.h>
/*
* Convenience method to throw a quick alert to the user
*/
void UIAlertViewQuick(NSString* title, NSString* message, NSString* dismissButtonTitle);
@interface UIAlertView (Helper)
@end
in UIAlertView+Helper.m
:
//
// UIAlertViewHelper.m
// CocoaHelpers
//
// Created by Shaun Harrison on 10/16/08.
// Copyright 2008 enormego. All rights reserved.
//
#import "UIAlertView+Helper.h"
void UIAlertViewQuick(NSString* title, NSString* message, NSString* dismissButtonTitle) {
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:title
message:message
delegate:nil
cancelButtonTitle:dismissButtonTitle
otherButtonTitles:nil
];
[alert show];
[alert autorelease];
}
@implementation UIAlertView (Helper)
@end
затем в вашем собственном приложении - конечно, используя Reachability. Например:
- (void) updateInterfaceWithReachability: (Reachability*) curReach;
UIAlertViewQuick(@"You're offline!", @"Sorry, it looks like you lost your Internet connection. Please reconnect and try again.", @"OK");
Я использую этот помощник во многих своих приложениях, потому что он довольно просто предоставляет пользователю представление alertView.
Надеюсь, это поможет!