Tag: ios6

UICollectionView声明失败

我得到这个错误在UICollectionView执行insertItemsAtIndexPaths 断言在以下失败: -[UICollectionViewData indexPathForItemAtGlobalIndex:], /SourceCache/UIKit/UIKit-2372/UICollectionViewData.m:442 2012-09-26 18:12:34.432 *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'request for index path for global index 805306367 when there are only 1 items in the collection view' 我已经检查,我的数据源只包含一个元素。 任何见解为什么会发生这种情况? 如果需要更多的信息,我可以肯定地提供。

在UITextView的NSAttributedString上设置字体忽略行间距

我试图在iOS 6中设置一个属性string到UITextView。问题是,如果我尝试设置属性string的字体属性,行间距将被忽略。 但是,如果我不设置字体,并使用默认字体,则行间距工作。 NSString *string = @" Hello \n world"; attrString = [[NSMutableAttributedString alloc] initWithString:string]; NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy]; paragraphStyle.minimumLineHeight = 50; // setting the font below makes line spacing become ignored [attrString addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:20] range:NSMakeRange(0, string.length)]; [attrString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, string.length)]; mainTextView.attributedText = attrString; 任何想法发生了什么?

在reloadItemsAtIndexPaths之后避免UICollectionView的animation

UICollectionView在reloadItemsAtIndexPaths被调用(淡入淡出animation)后animation的项目。 有没有办法避免这个animation? iOS 6

在UICollectionView上dynamic设置布局会导致无法解释的contentOffset更改

根据苹果公司的文档(并且在WWDC 2012上),可以dynamic地在UICollectionView上设置布局,甚至可以animation变化: 您通常在创build集合视图时指定布局对象,但也可以dynamic更改集合视图的布局。 布局对象存储在collectionViewLayout属性中。 设置这个属性可以直接更新布局,而不需要animation改变。 如果要为更改设置animation,则必须调用setCollectionViewLayout:animated:方法。 但是,在实践中,我发现UICollectionView对contentOffset进行了无法解释甚至无效的更改,导致单元格错误移动,导致该function几乎无法使用。 为了说明这个问题,我将下面的示例代码放在一起,这些代码可以附加到放入故事板的默认集合视图控制器中: #import <UIKit/UIKit.h> @interface MyCollectionViewController : UICollectionViewController @end @implementation MyCollectionViewController – (void)viewDidLoad { [super viewDidLoad]; [self.collectionView registerClass:[UICollectionViewCell class] forCellWithReuseIdentifier:@"CELL"]; self.collectionView.collectionViewLayout = [[UICollectionViewFlowLayout alloc] init]; } – (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return 1; } – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { UICollectionViewCell *cell = [self.collectionView dequeueReusableCellWithReuseIdentifier:@"CELL" forIndexPath:indexPath]; cell.backgroundColor = […]

如何更改iOS 7或6中的导航栏颜色?

我想更改导航栏颜色的颜色,但是我不确定是否应该更改颜色或背景。 我知道iOS 7是一个更平坦的devise(甚至build议删除渐变 ),但我无法破译这两个。 即使我设置了背景颜色,它也不会做任何事情。 在这个图像中,背景被设置为绿色,但是酒吧仍然是蓝色的:

日志消息我没有要求在Xcode 4.5与iOS 6.0

因为我更新Xcode到版本4.5,并开始build立这样的iOS 6日志消息不断出现: ADDRESPONSE – ADDING TO MEMORY ONLY 我从来没有要求(至less不自觉)。 我需要做些什么来阻止这些消息? 他们的起源是什么?

在UICollectionViewController中进行刷新

我想在iOS 6的UICollectionViewController实现下拉刷新。这很容易实现与UITableViewController ,如下所示: UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; [refreshControl addTarget:self action:@selector(startRefresh:) forControlEvents:UIControlEventValueChanged]; self.refreshControl = refreshControl; 上面实现了一个很好的液滴animation作为本地部件的一部分。 由于UICollectionViewController是一个“更进化”的UITableViewController人们会期望有一些UICollectionViewController的function,但我无法find一个引用到任何内置的方式来实现这一点。 有没有简单的方法来做到这一点,我俯瞰? UIRefreshControl可以用UIRefreshControl以某种方式使用,尽pipe标题和文档都指出它是用来与表视图?

在UITableViewController中使用UISearchDisplayController时声明失败

我一直在尝试添加简单的searchfunction到我的应用程序中的TableViewController。 我跟随了Ray Wenderlich的教程。 我有一个tableView与一些数据,我添加了故事板中的search栏+显示控制器,然后我有这样的代码: #pragma mark – Table View – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"BreedCell" forIndexPath:indexPath]; //Create PetBreed Object and return corresponding breed from corresponding array PetBreed *petBreed = nil; if(tableView == self.searchDisplayController.searchResultsTableView) petBreed = [_filteredBreedsArray objectAtIndex:indexPath.row]; else petBreed = [_breedsArray objectAtIndex:indexPath.row]; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.textLabel.text = petBreed.name; return cell; […]

支持的方向与应用程序没有共同的方向,而且应该是返回YES'

我的应用程序(iPad; iOS 6)是一个风景只有应用程序,但是当我尝试使用UIPopoverController来显示照片库时,会引发此错误: Supported orientations has no common orientation with the application, and shouldAutorotate is returning YES. 我试过改变很多代码,但我没有运气。

使用iOS 6时设置UITableViewCell样式UITableView dequeueReusableCellWithIdentifier:forIndexPath:

我想解决如何设置UITableViewCellStyle在UITableViewCellStyle使用iOS 6中的新方法。 以前,在创buildUITableViewCell我会在调用initWithStyle:时更改UITableViewCellStyle枚举来创build不同types的默认单元格initWithStyle:但从我所能收集的情况来看,情况已不再是这样。 UITableView的Apple文档指出: 返回值 :具有相关重用标识符的UITableViewCell对象。 此方法始终返回一个有效的单元格。 讨论 :出于性能原因,表视图的数据源通常应该在将单元格分配给其tableView:cellForRowAtIndexPath:方法中的行时重用UITableViewCell对象。 表视图维护数据源标记为可重用的UITableViewCell对象的队列或列表。 当被要求为表视图提供一个新的单元格时,从你的数据源对象调用这个方法。 此方法将取消现有单元格(如果有),或根据您之前注册的类或nib文件创build新单元格。 重要 :在调用此方法之前,必须使用registerNib:forCellReuseIdentifier:或registerClass:forCellReuseIdentifier:方法注册类或nib文件。 如果您为指定的标识符注册了一个类,并且必须创build一个新的单元格,则此方法通过调用其initWithStyle:reuseIdentifier:方法来初始化该单元格。 对于基于笔尖的单元格,此方法从提供的nib文件加载单元格对象。 如果现有的单元可用于重用,则此方法将调用单元的prepareForReuse方法。 这是我的新的cellForRowAtIndexPath在实现新方法后的样子: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdentifier = @"cell_identifier"; [tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:cellIdentifier]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath]; return cell; } 我到目前为止的代码工作正常,但总是返回默认样式。 我怎样才能改变这个,所以我可以创build其他样式的单元格,如UITableViewCellStyleDefault , UITableViewCellStyleValue1 , UITableViewCellStyleValue2和UITableViewCellStyleSubtitle ? 我不想子类UITableViewCell ,我只是想改变默认的types,因为我可以做iOS 6之前。看起来很奇怪,苹果将提供增强的方法,但用最less的文档来支持其实施。 有没有人掌握了这个,或者遇到类似的问题? 我努力寻找任何合理的信息。