小编tes*_*ing的帖子

无限滚动UICollectionView的两个方向与部分

我有一个类似于iOS日历的月视图,并且UICollectionView使用了一个.现在,实现无限滚动行为会很有趣,这样用户可以在每个方向上垂直滚动,它永远不会结束.现在的问题是如何以有效的方式实施这种行为?这是我现在发现的:

基本上,您可以检查是否到达当前滚动视图的末尾.您可以在里面scrollViewDidScroll:或里面查看collectionView:cellForItemAtIndexPath:.将另一个内容添加到数据源会很简单,但我认为还有更多内容.如果您只添加数据,则只能向下滚动.用户应该能够向两个方向滚动(向上,向下).不知道是否reloadData会这样做.也contentOffset将改变,不应该有跳跃行为.

另一种可能性是使用WWDC 2011的Advanced ScrollView Techniques中显示的方法.这里用于设置到中心,子视图的帧被调整到距离中心相同的距离.如果我没有部分,这种方法可以正常工作.如何使用部分?layoutSubviewscontentOffsetUIScrollView

我不想使用高值的部分来伪造无限滚动,因为用户会找到结束.我也不使用任何分页.

那么如何为集合视图实现无限滚动?

编辑:

现在我尝试增​​加部分的数量,如果我到达结束UICollectionView.要显示新部分,必须调用reloadData.在调用此方法时,所有当前可用部分的所有计算都将再次完成!滚动浏览集合视图时,此性能问题会导致严重的断断续续,如果向下滚动,则会变得越来越慢.不知道是否可以在后台线程上转移这项工作.通过这种方法,如果您进行了所需的调整,可以向上和向下滚动.

赏金:

现在,我正在为回答这个问题提供赏金.我对如何实现iOS日历的月视图感兴趣.详细介绍无限滚动的工作原理.它在两个方向上工作(向上,向下),它永远不会结束(真正的无限 - 不重复).也没有任何延迟(即使在iPhone 4上).我想使用UICollectionView和数据由不同的部分组成,每个部分有不同数量的项目.必须做一些计算才能得到下一部分.我不需要日历部分 - 只有部分中不同项目的无限滚动行为.随意提问.

添加部分:

public override void Scrolled(UIScrollView scrollView)
{
    NSIndexPath[] currentIndexPaths = currentVisibleIndexPaths();

    // if we are at the top
    if (currentIndexPaths.First().Section == 0)
    {
        NSIndexPath oldIndexPath = NSIndexPath.FromItemSection(0, 0);
        UICollectionViewLayoutAttributes attributes_before = this.controller.CollectionView.GetLayoutAttributesForItem(oldIndexPath);
        CGRect before = attributes_before.Frame;
        CGPoint contentOffset = this.controller.CollectionView.ContentOffset;
        this.controller.CollectionView.PerformBatchUpdatesAsync(delegate …
Run Code Online (Sandbox Code Playgroud)

calendar uiscrollview ios infinite-scroll uicollectionview

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

在Visual Studio 2015中禁用IntelliSense

有没有办法在Visual Studio 2015中禁用IntelliSense?我找到的信息都是针对旧版本的VS,但不适用于VS 2015.

intellisense visual-studio visual-studio-2015

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

是否可以在XAML(Xamarin.Forms)中混合使用OnIdiom和OnPlatform?

对于UWP,我需要一个不同大小的列的宽度Grid.此外,平板电脑和智能手机的价值应该不同.

以下代码崩溃了应用程序

<ColumnDefinition>
    <ColumnDefinition.Width>
        <OnIdiom.Phone>
            <OnPlatform x:TypeArguments="GridLength" iOS="*" Android="*" WinPhone="100" />
        </OnIdiom.Phone>
        <OnIdiom.Tablet>
            <OnPlatform x:TypeArguments="GridLength" iOS="*" Android="*" WinPhone="200" />
        </OnIdiom.Tablet>
    </ColumnDefinition.Width>
</ColumnDefinition>
Run Code Online (Sandbox Code Playgroud)

在xmlns http://xamarin.com/schemas/2014/forms中找不到OnIdiom.Phone

代码在ViewCell.所以我不能使用额外的ResourceDictionary,也OnSizeAllocated()不能在代码隐藏文件中使用.

是否有可能使用OnIdiomOnPlatform在一起?

xaml mobile-devices xamarin xamarin.forms mobile-development

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

以图像为中心,上面有链接

是否可以通过将一个类设置为img标签而没有副作用来居中图像?问题如下:我在图像周围有一个锚点.如果我使用以下CSS

.aligncenter {
    clear: both;
    display: block;
    margin-left: auto;
    margin-right: auto;
}
Run Code Online (Sandbox Code Playgroud)

这个(剥离)HTML:

<a href="/path/to/image.jpg" class="fancybox" rel="fancybox" title="System">
    <img src="/path/to/image.jpg" title="System" class="aligncenter">
</a>
Run Code Online (Sandbox Code Playgroud)

链接占用主div的整个宽度.这意味着不仅图像是可点击的 - 图像周围的空间(实际上是整个宽度)也是可点击的.这是通过CSS display: block. 在此输入图像描述

如何在不使用父div的情况下居中图像?我不希望整个区域可点击.

背景:您可以阅读此主题.它是关于Wordpress和内置编辑器.他自动aligncenter在图像上生成类(如果用户按下中心按钮).我需要这个用于我自己的主题.根据主持人的说法,这应该只是一个CSS问题,而不是在Wordpress中更改代码.

css wordpress image editor center

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

Xamarin.Forms:删除Button内的填充

我想要一个小按钮.按钮的高度为30.在某些平台(Android,UWP)上,按钮内的文本被切断.那是因为文本和外边框之间有填充.

一种选择是使按钮更大,但文本有足够的空间.是否有设置内部填充的选项?

button padding xamarin xamarin.forms

11
推荐指数
3
解决办法
9708
查看次数

如何从UIWebview或dealloc UIWebview中删除缓存

每次我加载一个新页面时UIWebView,前面加载的页面会显示很短的时间.

我该如何清除缓存?另一种可能性是dealloc UIWebview.我试过了,但我UIWebView总是"空".应该如何allocdealloc在这种情况下怎么办?

我注意到它UIWebView消耗了大约10 MB RAM.现在UIWebView加载了ViewController.视图是自动释放的,UIWebView也是自动释放的.每次取消分配WebView不是更好吗?

解:

- (void) viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    CGRect frame = CGRectMake(0, 0, 320, 480);
    self.webView = [[[UIWebView alloc]initWithFrame:frame] autorelease];
    self.webView.scalesPageToFit = YES;
    [self.view addSubview:self.webView];
}

- (void) viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];

    [self.webView removeFromSuperview];
    self.webView = nil;
}
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c uiwebview

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

在列名称之前登录SQL语句

我在PHP文件中有一个INSERT语句,其中符号(@)出现在列名前面.

@ field1,@ field2,

这是一个MySQL数据库.符号是什么意思?

编辑: PHP脚本中
没有 SET @field1 := 'test'.PHP脚本读取csv并将数据放入表中.是否可以将其误用为评论功能?

<?php
$typo_db_username = 'xyz';  //  Modified or inserted by TYPO3 Install Tool.
$typo_db_password = 'xyz';  //  Modified or inserted by TYPO3 Install Tool.

// login
$_SESSION['host'] = "localhost";
$_SESSION['port'] = "3306";
$_SESSION['user'] = $typo_db_username;
$_SESSION['password'] = $typo_db_password;
$_SESSION['dbname'] = "database";


$cxn = mysqli_connect($_SESSION['host'], $_SESSION['user'], $_SESSION['password'], $_SESSION['dbname'], $_SESSION['port']) or die ("SQL Error:" . mysqli_connect_error() );
mysqli_query($cxn, "SET NAMES utf8");

$sqltrunc = "TRUNCATE TABLE tablename";
$resulttrunc = mysqli_query($cxn,$sqltrunc) or …
Run Code Online (Sandbox Code Playgroud)

mysql sql symbols at-command

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

当使用位置:fixed和z-index的背景滑块时,悬停在菜单上会消失

我发现如果我想进入第二级菜单,主菜单中的悬停效果会消失.在这里您可以找到示例:

http://bfb.bplaced.net/ie/

HTML:

<div id="background-slider">
    <a href="http://www.hdwallpapersarena.com/wp-content/uploads/2012/10/Opera-Background-Blue-Swirls.jpg"></a>
    <a href="http://www.hdwallpapersarena.com/wp-content/uploads/2012/10/green-abstract-background.jpg"></a>
</div>
<div id="menu">
    <nav>
        <ul class="nav-level-1">
            <li class="level-1 clearfix">
                <a href="unternehmen.html" class="level-1">Unternehmen</a>
                <ul class="nav-level-2">
                    <li class="level-2"><a href="/unternehmen/die-firma.html" class="level-2">Die Firma</a></li>
                    <li class="level-2"><a href="/unternehmen/das-team.html" class="level-2">Das Team</a></li>
                    <li class="level-2"><a href="/unternehmen/allgemeines.html" class="level-2">Allgemeines</a></li>
                </ul>
            </li>
        </ul>
        <div class="clearer"></div>
    </nav>
</div>
<div id="script-section" class="hidden">
    <script src="./js/jquery.superbgimage.min.js"></script>
    <script>
        $(document).ready(function(){
            // Options for SuperBGImage
            $.fn.superbgimage.options = {
                transition: 1,
                speed: 'slow',
                randomtransition: 0,
                slideshow: 1,
                slide_interval: 6000,
                randomimage: 0
            };

            // initialize SuperBGImage
            $('#background-slider').superbgimage().hide;
        });
    </script>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

#menu …
Run Code Online (Sandbox Code Playgroud)

html css internet-explorer z-index css-position

9
推荐指数
2
解决办法
970
查看次数

Xamarin.Forms:之后更改RelativeLayout约束

是否可以RelativeLayout在设置一次后更改a的约束?

在文档中我看到了类似的方法GetBoundsConstraint(BindableObject),但我认为只有拥有XAML文件才能使用它们.现在我正在尝试在代码中执行此操作.null如果我尝试,我会得到

RelativeLayout.GetBoundsConstraint(this.label);
Run Code Online (Sandbox Code Playgroud)

我发现的唯一方法是从布局中删除子项并再次使用新约束添加它.

例:

public class TestPage : ContentPage
{
    private RelativeLayout relativeLayout;
    private BoxView view;
    private bool moreWidth = false;

    public TestPage()
    {
        this.view = new BoxView
        {
            BackgroundColor = Color.Yellow,
        };

        Button button = new Button
        {
            Text = "change",
            TextColor = Color.Black,
        };

        button.Clicked += Button_Clicked;

        this.relativeLayout = new RelativeLayout();

        this.relativeLayout.Children.Add(this.view,
            Constraint.Constant(0),
            Constraint.Constant(0),
            Constraint.Constant(80),
            Constraint.RelativeToParent((parent) =>
            {
                return parent.Height;
            }));

        this.relativeLayout.Children.Add(button,
            Constraint.RelativeToParent((parent) =>
            {
                return parent.Width / 2;
            }),
            Constraint.RelativeToParent((parent) …
Run Code Online (Sandbox Code Playgroud)

c# layout xamarin xamarin.forms

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

将带有两个UIBarButtonItem的UIToolbar添加到UINavigationBar:可怜的UIToolbar以及iPhone 4怎么样

我正在跟随这里的第二个提示.在这篇技巧文章中,两个UIBarButtonItems放在UIToolbar中.最后,UIToolbar被添加到UINavigationBar中.现在我的问题:

1)UIToolbar顶部有一条白线.如果我增加UIToolbar的大小,则渐变是错误的.我在UIToolbar上使用以下大小:

    UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 90, 44.01)];
Run Code Online (Sandbox Code Playgroud)

我该怎样摆脱白线?看这里: 替代文字

问题是存在白色而不是灰色线.如果它是灰色的,一切都会很完美.

2)iPhone 3和iPhone 4的显示尺寸有何不同?我是否必须检查使用哪个iPhone然后加倍?

编辑:

这些按钮的创建方式类似于我从上述网站获取的以下示例:

// create a toolbar to have two buttons in the right
UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 133, 44.01)];

// create the array to hold the buttons, which then gets added to the toolbar
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:3];

// create a standard "add" button
UIBarButtonItem* bi = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:NULL];
bi.style = UIBarButtonItemStyleBordered;
[buttons addObject:bi]; …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch objective-c uinavigationbar uitoolbar

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