Tag: 目标C

无法绑定到mvvmcross中的ios表节单元格,子单元格按预期方式绑定

我试图创build一个TableView分组部分如下所示: 我绑定了一个表的列表。 一个组包含一些string属性和一个项目列表,而一个项目也包含一些string属性。 组和项目单元每个都有自己的类,它扩展了MvxTableViewCell 。 在每个单元格的内部,我绑定如下: 项目单元格: this.DelayBind(() => { var set = this.CreateBindingSet<ItemCellView, ItemCellViewModel>(); set.Bind(lblOne).To(item=> item.propertyOne); set.Apply(); }); 和集体单元: this.DelayBind(() => { var set = this.CreateBindingSet<GroupCellView, GroupCellViewModel>(); set.Bind(lblOne).To(group=> group.propertyOne); set.Apply(); }); 我在主视图中的MvxStandardTableViewSource扩展MvxStandardTableViewSource并使用重写的方法来获取表的各个单元格。 public override UIView GetViewForHeader返回一个组单元格视图,而protected override UITableViewCell GetOrCreateCellFor返回一个项目单元视图。 我的问题是,组视图单元格不绑定什么,而项目视图单元格绑定就好,即使我没有看到两者之间的明显差异。 组视图单元格正在构build,但是这只是没有发生在单元格内的绑定。 编辑:添加表视图源: private class TableSource : MvxStandardTableViewSource { private List<GroupCellViewModel> _groups; public new List<GroupCellViewModel> […]

MonoTouch – XCode组织者中更好的控制台输出

我们一直在玩新的MonoTouch NUnittesting项目,这是相当不错的。 我们已经在CI软件的Windows上运行了这些testing中的一些,我们在控制台上打印了大量的东西,看看在testing过程中出了什么问题。 如果我们为MonoTouch构build并运行这些testing,并在XCode的组织者中查看控制台,那么看起来很丑陋: Feb 20 10:34:57 unknown UIKitApplication:com.ourcompany.ourapp[0xab78][8329] <Notice>: [Our usually pretty rainbows and unicorn console output here] 有没有办法在iOS中清理这个输出? 至less用更有意义的东西replace“未知”,或者将其完全移除和UIKitApplication将会很好。 此外,我们不介意以某种方式调用NSLog而不是Console.WriteLine如果它能解决这个问题。

NSFetchedResultsController按名字或姓氏sorting

我基本上是试图用名字和姓氏,或者名字或姓氏来实现NSSortDescriptor? 但是有一个NSFetchedResultsController。 我正在阅读地址簿中的logging,并希望像地址簿一样显示它们。 logging将根据姓氏的第一个字母分类。 如果没有姓,则按名字sorting,如果没有名字,则按公司sorting。 目前我有 – (NSFetchedResultsController *)fetchedResultsController { if (_fetchedResultsController != nil) { return _fetchedResultsController; } NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; // read the contact list NSEntityDescription *entity = [Contact MR_entityDescriptionInContext:[NSManagedObjectContext MR_defaultContext]]; [fetchRequest setEntity:entity]; // sort the results by last name then by first name NSSortDescriptor *sort1 = [[NSSortDescriptor alloc] initWithKey:@"lastName" ascending:YES […]

调用iOS Alert时出现UI一致性错误

我有一个iOS Xamarin项目,我收到以下错误: UIKit Consistency error: you are calling a UIKit method that can only be invoked from the UI thread. 以下代码会发生此错误: 在我的欢迎视图页面中,我有一个名为SyncButton的button被点击。 该button的点击应该使用REST将数据与服务器进行同步。 在我的WelcomeController中我有: …. SyncButton.TouchUpInside += async (object sender, EventArgs e) => { SyncButton.Enabled = false; await welcomeDelegate.syncButtonCore (cred, iOSErrorAlert); SyncButton.Enabled = true; }; …. public void iOSErrorAlert(string LoginErrorTitle, string LoginErrorMessage){ var Alert = […]

setlocale()在iOS模拟器中不起作用?

更新:奇怪的是,setlocale()只在iOS模拟器上失败,所以我修改了问题标题。 它在实际设备上正常工作。 我正在使用iOS 6下的本地(C / C ++)代码,我需要格式化任意的wchar_tstring。 但是,在格式化包含Latin-1代码页外的代码点的string时, swprintf失败(返回值为errno = EILSEQ值-1)。 wchar_t buff[256]; swprintf(buff, 256, L"\u00A9 %ls", L"ascii"); // works swprintf(buff, 256, L"\u03A0 %ls", L"ascii"); // will return -1 在问这里的相关问题之后,问题似乎是语言环境设置不正确(我已经validation该解决scheme在Mac OS X下工作)。 但在iOS 6下似乎没有效果: #include <locale.h> setlocale(LC_CTYPE,""); 按照这里的说明,我已经手动复制/添加区域设置文件到我的项目,并设置PATH_LOCALE环境variables,但问题依然存在: NSString* resourcePath=[[NSBundle mainBundle] resourcePath]; setenv("PATH_LOCALE", [resourcePath UTF8String], 1); setlocale(LC_CTYPE,"en_US.UTF-8"); 有谁知道我可以如何让setlocale()在iOS 6下工作(同时还有苹果商店接受的应用程序)?

不能将UIViewController仅限制为纵向

我在UINavigationControllerembedded我的应用程序,我希望我的大部分ViewControllers除了一个是Portrait,我已经阅读了很多问题,但是找不到一个适合我的正确答案。 在我的目标中,我select了“ Device Orientation : Portrait ,“ Landscape Right 我将这添加到我的第一个ViewController: -(BOOL)shouldAutorotate{ return NO; } -(NSUInteger)supportedInterfaceOrientations{ return (UIInterfaceOrientationPortrait); } 但是当我旋转设备左侧的ViewController旋转以及。 为什么它在旋转?

从日程表中删除正确的CCSprite

在我解释我的问题之前,我对这个项目的工作做了非常不完整的说明 – 我的问题是 – 当我想检查损坏的时间到了,我想从数组中删除该对象! 我已经尝试删除它在checkForDamage中,但因为这与ccTime它只是删除每个对象(当我使用removeObjectAtIndex:0摆脱第一个)。 我不能把它放在stopCheckDamage因为当第一个的伤害被检查的时候,玩家不妨放下另一个炸弹。 checkForDamage工作得很好,当用户被击中,我break; 它并调用stopCheckDamage。 我的问题是当用户没有被击中,因为那么不存在的精灵留在数组中,只是弄乱了东西。 我一直在想每一个我知道的方式,如果玩家没有被击中,我似乎无法find一种方法在延迟三秒后删除一个特定的对象。 我还为相关的代码做了一个pastebin,你可以在这里find它

如何从页脚内的button传递indexPath继续?

我正在做一个自定义布局collectionView,它有被子看,每个部分都有一个页脚。 两个button是在页脚内,每个button都有一个segue到另一个视图(我使用IB设置segues)。 页脚有它自己的indexPath在UICollectionViewFlowLayout类(我在哪里做了一个自定义的布局)分配。 footer的indexPath是这样的 – {section – row} {0-0} {1-0} {2-0} …. 我想保持这个indexPath信息在另一个链接到两个button的视图使用。 我试过“convertPoint:toView:… indexPathForRowAtPoint”的方式,但没有奏效。 我认为这是因为button不属于collectionViewItem,但属于页脚。 在这种情况下,传递每个footerView的indexPath的最好方法是什么? 代码示例的任何解决scheme将不胜感激。 // CollectionView DataSource – (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath { Footer *footerview = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionFooter withReuseIdentifier:@"Footer" forIndexPath:indexPath]; // set button images and labels [footerview setButton]; // debug code : show current section number footerview.footerLabel.text = […]

获得CABasicAnimation的即时价值

当我正在执行一个游戏时,我只是一个事情的前面,我觉得这很容易,但是不知道如何解决这个问题。 我有点新的目标,你可以看到我的名誉:( 问题是,我有一个animation,这是正确的。 这里是代码: CABasicAnimation * bordgauche = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"]; bordgauche.fromValue = [NSNumber numberWithFloat:0.0f]; bordgauche.toValue = [NSNumber numberWithFloat:749.0f]; bordgauche.duration = t; bordgauche.repeatCount = 1; [ImageSuivante.layer addAnimation:bordgauche forKey:@"bordgauche"]; 我想获得我的形象的当前位置。 所以我使用: CALayer *currentLayer = (CALayer *)[ImageSuivante.layer presentationLayer]; currentX = [(NSNumber *)[currentLayer valueForKeyPath:@"transform.translation.x"] floatValue]; 但我不明白。 我得到一次“当前= 0.0000”,这是起始值,当我使用nslog打印它,而不是其他人。 我不知道如何一直得到我的形象currentX的即时位置。 我希望我是可以理解的。 谢谢你的帮助 :)

滚动时如何添加更多的数据,而不删除数组中的以前的数据?

我有问题试图让用户滚动到底部,如果他们到最后我想通过调用我的服务器加载更多的行。 我正在使用AFNetworking的呼叫,并在完整的callback我重新加载的数据,但是,当它调用更多的数据擦除之前,我想它添加更多。 这是我现在的代码: -(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *) cell forRowAtIndexPath:(NSIndexPath *)indexPath { if(indexPath.row + 50 > [self.userIds count]) //self.array is the array of items you are displaying { [self getMoreFollowing]; //If it is the last cell, Add items to your array here & update the table view } } -(void)getMoreFollowing { AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; […]