小编kzi*_*zia的帖子

在UICollectionView的底部加载其他单元格

当用户滚动到底部时,我正在尝试自动获取并加载下一页单元格UICollectionView.

我可以通过添加一个这样做UIButtonUICollectoinView页脚.当用户滚动到页脚并触摸按钮时,会正确添加新单元格.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调用该方法,但整个 …

ios uicollectionview

12
推荐指数
3
解决办法
2万
查看次数

检测UICollectionView的上拉或拖动

当用户滚动到UICollectionView中第一页图像的底部时,我试图想出一种自动加载下一页图像的方法.UITableView(iOS 6)具有用于类似目的的refreshControl("Pull to refresh"),可用于刷新或类似的东西.UICollectionView是否有类似的选项?

有没有办法检测UICollectionView被拖动到最后一行单元格之外,或者是否显示页脚(位于最后一行单元格下方).然后,此操作可用于触发我的方法以加载下一页图像.

objective-c ios ios6 uicollectionview

7
推荐指数
1
解决办法
1万
查看次数

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 uicollectionview

5
推荐指数
2
解决办法
1万
查看次数

为什么我的WatchKit扩展程序会在实际的Apple Watch上导致"等待附加"消息,而不是在模拟器中?

我有一个已发布的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.

xcode ios apple-watch watchkit

5
推荐指数
1
解决办法
3082
查看次数

如何检测Web服务器上是否存在文件

在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是否确实存在.

objective-c ios

1
推荐指数
1
解决办法
721
查看次数

UICutton在UICollectionView页脚中

我是使用UICollectionView的新手.我使用流布局在集合视图中创建了一个页脚部分,并希望在那里添加一个UIButton.我怎样才能做到这一点?

[flowLayout setFooterReferenceSize:CGSizeMake (320,50)];
Run Code Online (Sandbox Code Playgroud)

objective-c ios6

1
推荐指数
1
解决办法
3680
查看次数