【发布时间】:2011-11-13 13:46:12
【问题描述】:
我使用 Apple 的 Reachability 类,它使用警报告诉用户连接不可用或连接丢失,它工作正常。但是,我想将警报更改为更直观的东西。我想加载一个笔尖,告诉用户没有活动连接,但笔尖没有加载。我也尝试加载我的其他笔尖,但它也没有加载笔尖。
- (BOOL) checkNetworkStatus:(NSNotification *)notice
{
// called after network status changes
NetworkStatus internetStatus = [internetReachable currentReachabilityStatus];
switch (internetStatus)
{
case NotReachable:
{
NSLog(@"The internet is down.");
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"No Internet Connection" message:@"You are currently not connected to a WI-FI or cellular Data.\nPlease make sure you are connected." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
[alert show];
[alert release];
//NoConnection *noConn = [[NoConnection alloc] initWithNibName:@"NoConnecton" bundle:nil];
//[self presentModalViewController:noConn animated:NO];
//[NoConnection release];
self.isConnected = NO;
return NO;
break;
}
//more cases.........
警报部分工作正常,但加载笔尖的部分却不行。你能告诉我这里有什么问题吗?我在 viewWillAppear 中调用了这个函数。谢谢!
【问题讨论】:
-
代码是否可以在 viewwillapper 等其他任何地方工作?
-
我在 viewDidDLoad 中尝试过,但也没有用。我收到了警报,但没有收到笔尖。
-
很明显你的 nib 文件有问题 打开 nib 文件并查看是否一切正常,特别是查看文件的新所有者类,在自定义类中,
-
如果这不起作用并且您赶时间,您可以创建一个不同的视图来打开,而不是使用不同的 nib 文件打开相同的视图。这不是很推荐,但应该可以工作
-
试试这个 [self.navigationController presentModalViewController:detailView animated:YES];
标签: iphone objective-c ios reachability