Tag: 客观

长按uiTableView IOS更改单元格的select

在uitableview上正常的单元格select工作正常。 但是,当长按事件被称为一个单元格时,它会再次select先前select的单元格。 例如,如果用户select第一个单元,然后长按第二个单元,则为第二个单元调用长按事件,但是select再次返回到第一个单元。 这是我的代码: – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MyIdentifier"]; cell.selectionStyle = UITableViewCellSelectionStyleNone; //add longPressGestureRecognizer to your cell UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; //how long the press is for in seconds lpgr.minimumPressDuration = 1.0; //seconds [cell […]

合并video和audio:导出透明/空白video

我正在尝试合并video和audio。 如果我粘贴video在我的主要包,然后video合并罚款。 但是,如果我使用任何录制的video(来自每个播放),那么导出的video没有video就是audio。 我看了我的相关问题,但没有一个和我的问题一样。 任何想法,为什么我得到与video主要捆绑工作正常时,有声音的空白video? 是因为录制的video有一些不同的属性? 任何帮助,将不胜感激。 谢谢。 合并audio(来自AVRecorder的m4aaudio)和video(来自everplay统一的mp4video)代码: -(void)mergeAndSave//:(NSURL*) video_url { //Create AVMutableComposition Object which will hold our multiple AVMutableCompositionTrack or we can say it will hold our video and audio files. AVMutableComposition* mixComposition = [[AVMutableComposition alloc] init]; //Now first load your audio file using AVURLAsset. Make sure you give the correct path of […]

UITableView didSelectRowAtIndexPath从不调用

我有UITableView里面的UIViewController采用UITableViewDelegate & UITableViewDataSource协议。 numberOfRowsInSection和cellForRowAtIndexPath被实现。 故事板中有数据源和代表的出口。 TableViewselect单一select。 检查触摸时显示select。 我在模拟器上运行项目,触摸表单元格,得到了didHighlightRowAtIndexPath调用,但didSelectRowAtIndexPath或willSelectRowAtIndexPath永远不会被调用。 我忘了什么 什么可以影响TableView这种方式? PS我知道,有这样的问题很多,但我已经花了几个小时的谷歌search和阅读stackoverflow,仍然没有解决我的问题。 TestViewController.h: @interface TestViewController : ViewController <UITableViewDelegate, UITableViewDataSource> @end TestViewController.m: @interface TestViewController () @property (strong) IBOutlet UITableView *tableView; @end @implementation TestViewController – (void)viewDidLoad { [super viewDidLoad]; } – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"selected"); } – (void)tableView:(UITableView *)tableView didHighlightRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"highlighted"); } – (NSInteger)numberOfSectionsInTableView:(UITableView […]

uitableview重新sorting不起作用,源始终等于目的地

我有一个tableview不会重新sorting。 它看起来像moveRowAtIndexPath永远不会调用与destinationIndexPath不同的sourceIndexPath。 当我拉一排时,它会跳回到起始位置,就好像这排不支持移动一样。 我试图实现所有的“canMove / canEdit /build议”方法返回YES,但我观察到相同的行为。 这是怎么回事? – (void) tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath { NSLog(@"%d -> %d", [sourceIndexPath row], [destinationIndexPath row]); if ([sourceIndexPath row] == [destinationIndexPath row]) { return; } MyDomain *domain = [self getObject]; [domain.stuff exchangeObjectAtIndex:(NSUInteger) [sourceIndexPath row] withObjectAtIndex:(NSUInteger) [destinationIndexPath row]]; }

如何使浏览器在ios中滚动

我有一个视图,我想滚动我的tableview滚动。 这是每当我滚动我的tableview将向上滚动的视图。 但是这是当我这样做时会发生什么: 你可以看到在我的目标视图和tableview之间有一个黑色的空间。 在我scrollViewDidScroll我做到了这一点: CGPoint offset = scrollView.contentOffset; self.counter = 0; CGRect bounds = scrollView.bounds; CGSize size = scrollView.contentSize; UIEdgeInsets inset = scrollView.contentInset; float y = offset.y + bounds.size.height – inset.bottom; float h = size.height; float reload_distance = 10; float scrollViewHeight = scrollView.frame.size.height; float scrollContentSizeHeight = scrollView.contentSize.height; float scrollOffset = scrollView.contentOffset.y; self.tableData.contentInset = UIEdgeInsetsZero; […]

UICollectionView – 根据水平滚动更新数组索引path

您好我使用两个收集单元格来显示数据,子集合视图值是基于主集合视图。 我有video列表,当我selectvideo在表即时通讯完整的数组在索引path,以便主集合视图将显示基于选定的数组的索引path。 它显示正常,但是当我滚动水平,我传递可见的单元格indexPath数据来获取子集合查看数据。 但是,当我滚动主集合视图,在indexPath数组不会更新基于主集合视图它始终显示相同的IndexPath从video列表(前视图控制器)。 如何更新基于水平滚动的主集合视图数组。 我想要离开这个场景 – 例如VIdeo列表数组是1,2,3,4 我select3索引,并传递给videolist数组的collections视图,显示选定的索引path行值,当我向右滚动索引path应该增加到4左右它应该减less到2,对于video上select的任何值列表数组。 主集合视图应该基于传递的索引path工作,并根据其索引path行事 我的代码 – – (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { if(self.childCollectionView ==collectionView) { return [self.array_ChildElements count]; } else { return [self.array_VideoList count]; } } – (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { if (collectionView ==self.collectionView) { VVCollectionCell *cell = (VVCollectionCell *)[self.collectionView dequeueReusableCellWithReuseIdentifier:@"VVCollectionCell" forIndexPath:indexPath]; VVSystems *obj; if (self.iscalledFromVideoLIst) { obj […]

在桌面单元格中的自我成长标签

我在Objective C使用Tableview 。 我有一个TableView单元格中的4个标签。 我想根据内容大小展开Comment Body标签和Answer Body标签。 如何使用AutoLayout。 请帮帮我 如何根据内容设置标签的dynamic高度? tableview的ScreenShot如下所示。

如何重新创build静态单元格支持UITableViewController?

我有很多共同的逻辑,因此我所有的viewController从BaseViewController,BaseDetailsViewController或BaseWebViewControllerinheritance。 最后两个inheritance自从UIViewControllerinheritance的BaseViewController。 问题是我不能使用tableViews静态单元格,因为我的BaseDetailsViewController不是从UITableViewControllerinheritance。 我从来没有使用和inheritanceUITableViewController,因为可以通过从UIViewControllerinheritance,使用添加的UITableView并实现数据源和委托方法来实现。 因此,对于表单types的屏幕(SignUp或其他数据input屏幕),我使用我自己的BaseDetailsViewController,它添加了方便的方法(inputvalidation,自定义样式,滚动键盘,处理input字段导航等) 使用UITableViewController有两个真正的好处:1)键盘滚动(如果你使用文本字段)和2)在屏幕上轻松创build你的表单UI元素。 第一个好处是我无关紧要,因为我已经在BaseDetailsViewController里面自己实现了这个东西。 关于第二个好处,我在scrollView中创build了我的表单,这给了很大的灵活性,但是它有点更多的努力(特别是当需要更新屏幕时)。 因此,我听到有些人实现了自己的UITableViewController,然后使它从BaseViewControllerinheritance。 所以我开始深入这个方法。 到目前为止,我遇到了这两种方法: 重新创build你自己的tableVC 。 不清楚如何使它适用于静态单元格。 目前我的演示应用程序崩溃,如果我的ReplaceTableViewController没有实现numberOfRows和cellForRow,并不显示静态单元格,如果我用虚拟内容实现它们。 方法 – swizzling 。 不清楚如何通过为UITableViewController注入baseViewControllerinheritance来更改类inheritance,但还是不清楚需要添加哪些方法。 有谁试过,想分享? 更新我不使用故事板,因为我促进干净的MVC – 作为组件的每个屏幕应该有自己的模型,视图(Xib)和控制器,所有存储在单独的文件,以消除大型应用程序项目中的多个开发人员的合并冲突(30+屏幕)。 因此,embedded式segue到tableViewController的容器视图也不是一个选项。 UPDATE2如果有人想看看我为什么和怎么做这个,这里有一个链接到我的开源模板基于新的项目生成器框架 ,我最近开始发布。

获得UIView的可视化

假设UIView只是沿着边缘被裁剪(没有其他的视图在中间的某个地方被CGRect ,把任意UIView的可见矩形作为CGRect ,最简单的方法是什么? 为了清楚起见,这个方法不仅要检索相对于视图的超级视图的可见矩形。 但相对于所有的祖先来说,至less也是相对于所有的兄弟姐妹来说都是如此。

UITextfield becomeFirstResponder返回NO

我已经在我的应用程序中实现了UITextFields上的标准“下一个”function(按下一步将移动到下一个适当的文本字段)。 大多数情况下,这种方式运行良好,并将转移到适当的文本框没有问题。 但是由于某些原因,textField在我要求它成为第一响应者的时候会返回NO,我不知道为什么。 关于textfields / view的一些信息: 该视图有多个UITableViews,其中一些UITableViewCells有UITextfields我想成为他们的第一响应者,其他人不。 创build表时,我通过主视图子视图循环查找所有第一响应者,并将其添加到第一响应者数组(_firstResponders – variables名)。 当需要下一个响应者时,每个单元通过一个委托callback到主视图。 以下是我用来获得下一个响应者的代码: //get the current first responders index NSInteger currentIndex = [_firstResponders indexOfObject:currentResponder]; // if the current index plus 1 is less than the overall count of first responders on this view then continue, else resign the responder as no more are avilable if((currentIndex+1) < […]