Tag: 客观

UICollectionView:用于分页的外屏自动滚动

我想通过下面的代码滚动我的应用程序中的UICollectionView 。 int pages = ceil(aCollectionView.contentSize.height / aCollectionView.frame.size.height); for (int i = 0; i < pages; i ++) { NSArray *sortedVisibleItems = [[aCollectionView indexPathsForVisibleItems] sortedArrayUsingSelector:@selector(compare:)]; NSIndexPath *lastItem = [sortedVisibleItems lastObject]; // 2.next position NSInteger nextItem = lastItem.item + 1; NSInteger nextSection = lastItem.section; NSIndexPath *nextIndexPath = [NSIndexPath indexPathForItem:nextItem inSection:nextSection]; [self takeImage]; dispatch_async(dispatch_get_main_queue(), ^ { [aCollectionView […]

尝试使用custon UITableViewCell时发生错误“此类不是键值编码兼容的密钥…”

我已经看到了关于清理笔尖连接的其他问题,但我不相信这是我的问题。 目前我正在导入一个自定义的UITableViewCell类,在VC的viewDidLoad中使用UITableView在VC中注册nib,如下所示: static NSString *cellIdentifier = @"cell"; UINib* cellNib = [UINib nibWithNibName:@"[nib for the custom cell]" bundle:[NSBundle mainBundle]]; [_theTableView registerNib:cellNib forCellReuseIdentifier:cellIdentifier]; 然后在VC中实现这个方法 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString* cellIdentifier = @"cell"; CustomTableCell* cell = [tableView dequeueReusableCellWithIdentifier:outgoingNoteIdentifier forIndexPath:indexPath]; return cell; } 如果我没有连接自定义单元格中的任何属性(只是标签和button),那么它加载正常,我可以看到与标签和button相关的图像。 当我试图只连接xib文件中的一个属性时,我得到了上面提到的错误。

如何从GCD返回UIImagetypes

我有一个名为“ComLog”的“UIImage”返回types的方法。 我想从这个方法返回一个图像。 在“ComLog”方法中,我使用GCD从数组中获取图像值。 我使用下面的代码,“NSLog(@”qqqqqqqqqqq%@“,exiIco)”打印'图像'的值,但NSLog(@“qqqqqqqqqqqq%@”,exiIco);“不要这样的细节: -(UIImage*) ComLog { ExibitorInfo *currentExibitor100 = [[ExibitorInfo alloc] init]; currentExibitor100 = [self.exibitorsArray objectAtIndex:0]; imageQueueCompanyLogo = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0ul); dispatch_async(imageQueueCompanyLogo, ^ { UIImage *imageCompanyLogo = [UIImage imageWithData:[NSData dataWithContentsOfURL: [NSURL URLWithString:[currentExibitor100 companyLogoURL]]]]; dispatch_async(dispatch_get_main_queue(), ^ { self.exibitorIcoImageView.image = imageCompanyLogo; exiIco = imageCompanyLogo; NSLog(@"qqqqqqqqqqq %@", exiIco); }); }); return exiIco; } – (void)viewDidLoad { [super viewDidLoad]; […]

尝试插入新的项目到UICollectionView,但一遍又一遍地获得相同的单元格

我的UICollectionView设置为3行3个部分。 我试图插入一个批量(数组)9的项目到CollectionView,但下面的代码,我得到了我的批量显示在所有3个部分的前3件事情。 分批:蓝色,红色,绿色,橙色,鱼,沙子,帽子,鞋子,黑色 显示当前结果: blue blue blue red red red green green green 当前代码: … [self.selectedSearches addObject:string]; [self.collectionView insertItemsAtIndexPaths:@[[NSIndexPath indexPathForRow:self.selectedSearches.count-1 inSection:0]]]; … 不知道我在做什么错。

在UITableView中从networking加载图像的更有效的方法是什么?

对于我的UITableView每个UITableViewCell ,我在后台线程中从网上下载一个图像。 然后我使用主线程更新单元格中的imageView。 dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){ //Background Thread // download the image in separate thread UIImage *image = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString: @"someurl.com" ] ] ]; dispatch_async(dispatch_get_main_queue(), ^(void){ // this is called in the main thread after the download has finished, here u update the cell's imageView with the new image cell.eventImageView.image = […]

使用多个自定义的UITableViewCells

我正在尝试实现分组样式的UITableView,如联系应用程序detailedView。 我想最上面的单元格是透明的,并在底部有一个UISegemtedControl。 当我尝试创build两种不同types的自定义单元格时,即使使用两个不同的cellIdentifiers,也只会加载第一个自定义单元格。 将不胜感激索姆的指导。 或者针对同一主题的一些很好的教程技巧。 – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { /* UIView *backView = [[UIView alloc] initWithFrame:CGRectZero]; backView.backgroundColor = [UIColor clearColor]; cell.backgroundView = backView; [backView release]; */ static NSString *cellIdentifier1 = @"DetailCellStyle1"; static NSString *cellIdentifier2 = @"DetailCellStyle2"; if (indexPath.section == 0) { // Load from nib DetailCellViewController *cell = (DetailCellViewController *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier1]; if […]

自定义表视图单元格

我为我的UITableView创build了一个自定义的UITableView Cell类。 但是,由于某些原因,我无法在单元格中设置值。 就像在userName和userImage这样的值不会显示何时加载表。 这个问题已经持续了几天。 下面是我的代码,为了简单起见,我使用了虚拟值。 如果有人可以请让我知道我做错了,这将不胜感激。 谢谢! 码 CustomCell.h @interface CustomCell : UITableViewCell { IBOutlet UILabel *userName; IBOutlet UIImageView *userImage; } @property(strong,nonatomic) IBOutlet UILabel *userName; @property(strong,nonatomic) IBOutlet UIImageView *userImage; @end CustomCell.m #import "CustomCell.h" @interface CustomCell () @end @implementation CustomCell @synthesize userName; @synthesize userImage; -(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) […]

困惑什么对象实际上包含捕获的图像时使用AVFoundation

我有一个使用AVFoundation的照片应用程序。 到目前为止,一切正常。 然而,令我困惑的一件事情是,被捕获的图像实际上包含了什么对象? 我已经NSLogging所有的对象和他们的一些属性,我仍然不知道捕获的图像包含在哪里。 这是我设置捕获会话的代码: self.session =[[AVCaptureSession alloc]init]; [self.session setSessionPreset:AVCaptureSessionPresetPhoto]; self.inputDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; NSError *error; self.deviceInput = [AVCaptureDeviceInput deviceInputWithDevice:self.inputDevice error:&error]; if([self.session canAddInput:self.deviceInput]) [self.session addInput:self.deviceInput]; self.previewLayer = [[AVCaptureVideoPreviewLayer alloc]initWithSession:self.session]; self.rootLayer = [[self view]layer]; [self.rootLayer setMasksToBounds:YES]; [self.previewLayer setFrame:CGRectMake(0, 0, self.rootLayer.bounds.size.width, self.rootLayer.bounds.size.height)]; [self.previewLayer setVideoGravity:AVLayerVideoGravityResizeAspectFill]; [self.rootLayer insertSublayer:self.previewLayer atIndex:0]; self.stillImageOutput = [[AVCaptureStillImageOutput alloc] init]; [self.session addOutput:self.stillImageOutput]; [self.session startRunning]; } […]

当UITableView完全重新加载

我有一个控件,部分或完全改变tableView的内容。 发生更改后,我设置了一个标志tableViewContentHasChanged : BOOL tableViewContentHasChanged = YES; [self.tableView reloadData]; tableViewContentHasChanged = NO; 我的问题出现在tableView:viewForHeaderInSection: 它在表视图重新加载后调用,所以我的标志在该方法内无效。 简而言之,当桌子完全重新加载时,观察正确的方式是什么,所以我可以将标志设置为NO ? 而且,我可能做错了什么?

请求成员tableView不是结构或联合

请帮助解决这个问题,我试图用coreData db填充我的表格单元格; 我正在移植一个从iPhone到iPad的例子,问题在于我的表格视图中的iPad。 我在用着: @interface FailedBanksViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, NSFetchedResultsControllerDelegate> 不是 @interface FailedBanksListViewController : UITableViewController <NSFetchedResultsControllerDelegate> 对于整个表格视图而言, 所以我得到的错误: “请求成员'tableView'的东西不是一个结构或联盟” 对于我的代码, 看下面的代码,我希望是唯一的问题: #import "FailedBanksViewController.h" #import "FailedBankInfo.h" @implementation FailedBanksViewController @synthesize context = _context; @synthesize fetchedResultsController = _fetchedResultsController; – (NSFetchedResultsController *)fetchedResultsController { if (_fetchedResultsController != nil) { return _fetchedResultsController; } NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription […]