当用户滚动到底部时,我正在尝试自动获取并加载下一页单元格UICollectionView
.
我可以通过添加一个这样做UIButton
的UICollectoinView
页脚.当用户滚动到页脚并触摸按钮时,会正确添加新单元格.UIButton
在页脚中可以再次触摸以添加更多页面.
我试图自动化它,所以当用户滚动到底部时,自动调用添加新单元格的正确方法:
- (UICollectionReuseableView *)collectionView: (UICollectionView *)collectionView viewForSupplementaryElementOfKind: (NSString *)kind atIndexPath: (NSIndexPath *) indexPath
{
// code for headerView
// ...
// code for footerView
MySupplementalFooter *footerView = nil;
if ( [kind isEqual:UICollectionElementKindSectionFooter] )
{
footerView = [self.collectionView dequeueReuseableSupplemntaryViewOfKind:kind withReuseIdentifier:@"FooterId" forIndexPath:indexPath];
if (LoadMoreIsEnabled)
{
footerView.loadMoreFooterButton.setHidden:NO];
[self loadMoreFooterButtonAction]; // calls the method to add cells to the dictionary for cv
} else
{
footerView.loadMoreFooterButton setHidden:YES];
}
return footerView;
}
}
Run Code Online (Sandbox Code Playgroud)
loadMoreFooterButtonAction
调用该方法,但整个 …
当用户滚动到UICollectionView中第一页图像的底部时,我试图想出一种自动加载下一页图像的方法.UITableView(iOS 6)具有用于类似目的的refreshControl("Pull to refresh"),可用于刷新或类似的东西.UICollectionView是否有类似的选项?
有没有办法检测UICollectionView被拖动到最后一行单元格之外,或者是否显示页脚(位于最后一行单元格下方).然后,此操作可用于触发我的方法以加载下一页图像.
我试图在UICollectionView中记住项目的索引(indexPath.item),稍后在替换视图然后恢复后滚动到该记忆项目.
记忆项目时,indexPath和indexPath.item是:
indexPath is: <NSIndexPath 0x1d87b380> 2 indexes [0, 32]
indexPath.item is: 32
Run Code Online (Sandbox Code Playgroud)
稍后为该项重新计算indexPath时,indexPath和indexPath.item为:
indexPath is: <NSIndexPath 0x1d8877b0> 2 indexes [0, 32]
item is: 32
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下方法滚动到记忆位置:
NSIndexPath *iPath = [NSIndexPath indexPathForItem:i inSection:0];
[self collectionView scrollToItemAtIndexPath:iPath atScrollPosition:UICollectionViewScrollPositionCenteredVertically animated:NO];
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
attempt to scroll to invalid index path
Run Code Online (Sandbox Code Playgroud) 我有一个已发布的iOS应用程序,我正在尝试为其添加WatchKit
扩展程序.
就目前而言,我所interface.storyboard
拥有的label
仅仅是一只用于验证整个建筑过程的手表.该应用程序在模拟器(iPhone 6(8.3))和Watch模拟器上运行良好.
当我在iPhone和Apple Watch上运行它时,它在iPhone上运行,安装在Apple Watch上,但是当它试图在Apple Watch上运行它时只显示等待状态.
Xcode中的错误表示"等待连接",当我尝试通过它连接时Xcode > Debug > Attach to Process
,它会显示"丢失与iPhone的连接".
我正在使用Xcode 6.3.1.
在iOS中检测Web服务器上是否存在文件(HTML)的正确方法是什么.使用以下方法检测myfile.html的存在始终返回true.
NSURL *url = [NSURL URLWithString:@"http://somewebsite.com/myfile.html"];
NSURLRequest *requestObject = [NSURLRequest requestWithURL:url];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:requestObject delegate:self];
if (theConnection) {
NSLog(@"File exists");
} else {
NSLog(@"File does NOT exist");
}
Run Code Online (Sandbox Code Playgroud)
我相信它返回到HTTP服务器的连接成功,而不是检查文件myfile.html是否确实存在.
我是使用UICollectionView的新手.我使用流布局在集合视图中创建了一个页脚部分,并希望在那里添加一个UIButton.我怎样才能做到这一点?
[flowLayout setFooterReferenceSize:CGSizeMake (320,50)];
Run Code Online (Sandbox Code Playgroud)