gpt4 book ai didi

iphone - 如果手机未连接到互联网,请加载不同的 Nib

转载 作者:行者123 更新时间:2023-12-01 17:00:28 25 4
gpt4 key购买 nike

我使用 Apple 的 Reachability 类,它使用警报告诉用户连接不可用或连接丢失,它工作正常。但是,我想将警报更改为更直观的东西。我想加载一个 Nib ,告诉用户没有事件连接,但 Nib 没有加载。我也尝试加载我的其他 Nib ,但它也没有加载 Nib 。

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

警报部分工作得很好,但加载 Nib 的部分却不行。你能告诉我这里有什么问题吗?我在 viewWillAppear 中调用了这个函数。谢谢!

最佳答案

您可以执行以下操作:

if ( ! isConnected )
{
NoConnection *noConn = [[NoConnection alloc] initWithNibName:@"NoConnecton" bundle:nil];
[self presentModalViewController:noConn animated:NO];
[NoConnection release];
}

关于iphone - 如果手机未连接到互联网,请加载不同的 Nib ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7358346/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com