Tag: ios5

如何从当前视图控制器的实现文件加载另一个视图控制器?

我需要创build一个应用程序,它具有一个login/启动窗体,然后是一个自定义的Google地图。 我是新来的iOS编程,并试图快速学习这个应用程序所需要的东西。 所以,我已经创build了login表单的前端和后端,它的工作原理。 我有一个动作,这是由“login”button触发,这将validation凭据,并触发一个错误或呈现Google Map。 我想在另一个视图控制器中显示Google Map来控制另一个xib文件。 我创build了视图控制器和xib文件。 我的问题是如何加载另一个视图控制器从当前视图控制器的实施文件中放置的操作? 现在,我有这个代码: UIViewController *mapViewController = [[BSTGMapViewController alloc] initWithNibName:@"BSTGMapViewController" bundle:nil]; 我怎样才能使它成为窗口的“根视图控制器”,并可能具有转换(考虑到我的逻辑是好的:D)?

AFNetworking(AFHttpClient)离线模式不适用于NSURLRequestReturnCacheDataDontLoad策略

我在我的应用程序中使用AFNetworking,并尝试通过使用caching数据(如果可用)使其在脱机模式下工作。 我希望在将请求caching策略设置为NSURLRequestReturnCacheDataDontLoad之后,getPath:parameters:success:failure:在离线状态下将成功caching数据。 但是,即使caching中存在数据(通过使用代码检查caching来validation),getPath在飞行模式下也会失败。 AFNetworking有一个线程github: https : //github.com/AFNetworking/AFNetworking/issues/378但似乎这个问题根本没有解决。 AFNetworking的作者只是简单地指出了苹果的文件 ,并表示: NSURLRequestReturnCacheDataDontLoad指定应使用现有的caching数据来满足请求,而不pipe其年龄或过期date。 如果高速caching中没有对应于URL加载请求的现有数据,则不会尝试从源数据源加载数据,并认为加载失败。 此常数指定与“脱机”模式类似的行为。 正如苹果所说,NSURLRequestReturnCacheDataDontLoad是专为离线模式devise的。 我在iOS6testing,我testing了NSURLCache和SDURLCache,都有相同的结果。 请求失败,错误消息: 2012-12-22 03:11:18.988 Testapp [43692:907] error:Error Domain = NSURLErrorDomain Code = -1009“Internet连接似乎处于脱机状态。 UserInfo = 0x211b87c0 {NSErrorFailingURLStringKey = http://Testapp.com/api/v1/photo/latest/,NSErrorFailingURLKey = http://Testapp.com/api/v1/photo/latest/,NSLocalizedDescription =互联网连接似乎是离线。,NSUnderlyingError = 0x211b9720“Internet连接似乎处于脱机状态。”}

查看后如何删除通知中心的推送通知

点击后是否有任何处理来自通知中心的推送通知,并在我的应用程序已经启动时将其删除?

UIAlertViewStylePlainTextInput返回键代理

我正在使用UIAlertView的新iOS 5function之一。 我创build一个像这样的UIAlertView: UIAlertView *scanCode = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Some Title", @"") message:nil delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:NSLocalizedString(@"OK", @""), nil]; [scanCode setAlertViewStyle:UIAlertViewStylePlainTextInput]; scanCode.tag = 1234; [scanCode show]; [scanCode release]; 我现在使用的代表是: -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (alertView.tag == 1234) { if (buttonIndex == 1) { //do something } } } } 现在我想模拟回车键,所以当用户点击返回键盘时,同样的事情发生时,按下警报的确定button。 我怎样才能做到这一点? 提前致谢!

如何从Objective-C中的Json响应获取值

从Json响应中获取数据时遇到问题。 这是一个示例数据结构: ( { AT = "<null>"; DId = 0; DO = 0; PLId = 33997; PdCatList = ( { PLId = 33997; PPCId = 0; pdList = ( { IsDis = 0; IsPS = 0; IsT = 1; PA = 1; PCId = 119777; } ); } ); PdId = 0; SId = 0; […]

提醒IOS 5 UITableView外观和devise

我想在IOS 5提醒应用程序中创build记事本的UITableView外观。 注意:1.垂直双线分隔符2.像UITableViewStyleGrouped中的情况一样,也可以用于组标题视图。

防止ios5中的自签名SSL证书

我使用基本HTTP身份validation的代码,请参阅下文。 这在IOS 5中工作正常。但现在我们将协议更改为https,我们使用假的自签名证书。 它也有效! 这似乎不安全。 有人知道你是否需要用这种方法来做某些事情来防止某些证书被接受? – (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge: (NSURLAuthenticationChallenge *)challenge { if ([challenge previousFailureCount] <= maxRetryCount ) { NSURLCredential *newCredential = [NSURLCredential credentialWithUser: userName password:password persistence:NSURLCredentialPersistenceForSession]; [[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge]; } else { NSLog(@"Failure count %d",[challenge previousFailureCount]); } }

当用户按下button显示dateselect器视图和selectdate,然后显示为button标题和进一步closuresdateselect器视图

我写了这个代码。 但不包括… NSLog是正确的date。 Datepicker也看到并selectdate。 但是,当我selectdate没有任何改变我的button标题和dateselect留在屏幕上。 我也想隐藏当用户selectdate… 其实我显示dateselect器视图时,用户按下button,然后selectdate和设置标题button并释放select器视图。 我使用ios 5 … [datePicker setHidden:NO]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]init]; [dateFormatter setDateFormat:@"MM/dd/yyyy"]; NSString *dateString = [dateFormatter stringFromDate:[self.datePicker date]]; NSLog(@"\n" "theDate: |%@| \n" , dateString); [self.DOBbutton setTitle:dateString forState:UIControlStateNormal];

iCloud同步不通过无处不在的容器发送数据

我一直在我的应用程序中使用iCloud一段时间,最近有一个问题,设备拒绝互相交谈。 或者至less这是我想到的,直到我开始logging合并发生的方法。 我的persistentStoreCoordinator按照我之前的一个问题进行了设置 。 问题是以下。 当设置我的managedObjectContext ,我添加一个观察者来查看NSPersistentStoreDidImportUbiquitousContentChangesNotification通知如下所示: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mergeChangesFrom_iCloud:) name:NSPersistentStoreDidImportUbiquitousContentChangesNotification object:coordinator]; coordinator被设置为NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator] 。 我的iCloud方法如下: – (void)mergeiCloudChanges:(NSNotification *)note forContext:(NSManagedObjectContext *)moc { NSLog(@"insert %@", [[note userInfo] valueForKey:@"inserted"]); NSLog(@"delete %@", [[note userInfo] valueForKey:@"deleted"]); NSLog(@"update %@", [[note userInfo] valueForKey:@"updated"]); [moc mergeChangesFromContextDidSaveNotification:note]; NSNotification *refreshNotification = [NSNotification notificationWithName:@"RefreshAllViews" object:self userInfo:[note userInfo]]; [[NSNotificationCenter defaultCenter] postNotification:refreshNotification]; } […]

UIPrintInteractionController的presentFromRect问题

我使用presentFromRect方法显示UIButton中的AirPrint选项,一切都按预期工作,但如果我一直按住button足够快,我的应用程序崩溃与EXC_BAD_ACCESS,可能是因为popup不释放。 即时通讯启用ARC使用Xcode 4.2。 任何帮助将是伟大的! 更新2:仅在iOS 5模拟器上出现问题,iPad 4.3模拟器按预期工作。 更新: 这是真正的问题: *终止应用程序,由于未捕获的exception'NSGenericException',原因:' – [UIPopoverController dealloc]达到popup仍然可见。 这里是代码: 在这里,我打电话给我的方法: PrintUtils* printUtils = [[PrintUtils alloc] init]; printUtils.delegate = self; [printUtils setHeader:@"Header"]; [printUtils print:self.webView fromRect:self.myButton.frame inView:self.menuView]; 我的方法: – (void)print:(UIWebView *)webView fromRect:(CGRect)rect inView:(UIView *)view { printController = [UIPrintInteractionController sharedPrintController]; [printController setDelegate:self]; if(!printController){ NSError* error = [[NSError alloc] initWithDomain:@"Print unavailable!" code:0 userInfo:nil]; [self […]