嗨朋友是iphone开发的新手.我很难在右侧的UIBarbutton项目上添加徽章值.我试过但我无法解决这个问题.谁能帮我.
提前致谢!
我正在使用Matt Gallagher GenericTableViewController控制我的想法UITableViews.我的数据源是NSFetchedResultsController.
http://cocoawithlove.com/2008/12/heterogeneous-cells-in.html
一切都运行正常,直到我尝试删除一个单元格.
我在View Controller中有以下代码:
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
// Delete the managed object.
NSManagedObjectContext *context = [wineryController managedObjectContext];
[context deleteObject:[wineryController objectAtIndexPath:indexPath]];
NSError *error;
if (![context save:&error]) {
// Handle the error.
}
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
}
}
Run Code Online (Sandbox Code Playgroud)
最后一行因控制台中相当冗长的解释而崩溃:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of rows in section 0. The number of rows contained in an …
我有一个UIView我想保存的UIImage.我这样做UIGraphicsBeginImageContext,它工作正常.但是当我将掩码应用于(view/layer.mask)中的图像时,我捕获的图像UIGraphicsBeginImageContext是错误的(在运行应用程序时屏蔽是有效的,但在尝试UIImage从a 获取时却没有UIView).有人遇到类似的问题?
我正在研究受UIPickerView启发的自定义值选择器.它看起来像这样:

正如您所看到的,此拾取器的主要特征之一是中央单元应该比其他单元更宽,以使其邻居在中央框架旁边可见.当您使用平移手势滚动选择器时,它应该动态更改中心值并根据上面的逻辑调整单元格.它的工作原理非常完美:

问题在于轻击手势.当用户通过点击它来选择选择器上的任何项目时,选择器试图滚动到该项目.但是,由于自定义布局UIScrollView滚动到错误点,因此它的偏移被更改了.看起来像这样:

当我尝试滚动到屏幕外单元格时,一切正常 - 该单元格不受布局的影响,并且它的坐标是正确的.这个问题仅针对可见细胞而上升.我完全没有任何关于如何解决这个问题的想法.你可以在这里找到整个项目:Carousel Collection View Test Project
请在下面找到一些重要的代码.
// CarouselLayout.m
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
NSArray *array = [super layoutAttributesForElementsInRect:rect];
CGRect visibleRect;
visibleRect.origin = self.collectionView.contentOffset;
visibleRect.size = self.collectionView.bounds.size;
CGRect center = CGRectMake(CGRectGetMidX(visibleRect) - 1.0, 0.0, 2.0, CGRectGetHeight(visibleRect));
CGFloat coreWidth = CGRectGetWidth(self.centralFrame) / 3.0;
for (UICollectionViewLayoutAttributes *attributes in array) {
if (CGRectIntersectsRect(attributes.frame, rect)){
CGFloat distance = CGRectGetMidX(visibleRect) - attributes.center.x;
CGFloat offset = 0.0;
CGRect coreFrame = CGRectMake(attributes.center.x - (coreWidth / 2.0), 0.0, coreWidth, CGRectGetHeight(self.centralFrame));
if (CGRectIntersectsRect(center, coreFrame)) { …Run Code Online (Sandbox Code Playgroud) objective-c custom-component ios uicollectionview uicollectionviewlayout
ios ×3
objective-c ×2
badge ×1
calayer ×1
cocoa-touch ×1
iphone ×1
mask ×1
uiimage ×1
uiview ×1