【问题标题】:TableViewController Horizontal Scrollbar for iOSiOS 的 TableViewController 水平滚动条
【发布时间】:2015-11-23 15:12:46
【问题描述】:

我遇到了 uisplitviewcontroller 的问题。主控制器是一个tabbarviewcontroller,子控制器只是一个webview。所以我在右侧和左侧显示了一些文档,我想在tableview中显示文档信息。

如图所示(我画了红色矩形),一些文本不适合单元格,我需要滚动它,但默认情况下,tableview 中没有水平滚动。如何解决这个问题?

我正在使用 xamarin.ios,但您可以提供我 obj-C 或 swift 代码或算法。

【问题讨论】:

    标签: ios uitableview horizontalscrollview


    【解决方案1】:

    1 可以增加tableView的宽度

    2 你可以将 UIScrollView 放在单元格上,其他标签在该滚动视图中移动,然后你可以滚动每个单元格的内容

    3 你可以在只读模式下使用 UITextView 而不是单元格中的第二个标签,滚动应该自动用于最后一个文本

    【讨论】:

    • 感谢您的回复。最简单的似乎 3. 一。我试了一下,它添加了垂直滚动,而不是水平滚动。我将它设置为可编辑的 false 。我错过了什么?
    【解决方案2】:

    我解决了这个问题。谢谢伊戈尔的想法。

    public CustomInformationCell (NSString cellId,int maxLenght,int totalCharLenght)
            : base(UITableViewCellStyle.Default, cellId)
    {
    
        _maxLength = maxLenght; //max lenght is the longest label length in order to making alignment
        SelectionStyle = UITableViewCellSelectionStyle.None;
        Accessory = UITableViewCellAccessory.None;
        ContentView.BackgroundColor = UIColor.White;
        detail = new UILabel();
        caption = new UILabel ();
        caption.TextColor = UIColor.FromRGB (48,110,255);
    
        _scrollView = new UIScrollView {
                Frame = new CGRect (0, 0, ContentView.Bounds.Width,  ContentView.Bounds.Height),
                ContentSize = new CGSize (ContentView.Bounds.Width + totalCharLenght, ContentView.Bounds.Height),
                BackgroundColor = UIColor.White,
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth
            };
    
            _scrollView.AddSubview (caption);
            _scrollView.AddSubview (detail);
    
            ContentView.AddSubviews(new UIView[] {_scrollView});
            //ContentView.AddSubviews(new UIView[] {caption,  detail});
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-16
      • 2011-03-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多