ios - 从 iOS10 中的 Today 小部件隐藏 "Show More"按钮

标签 ios objective-c widget today-extension

我正在构建一个 iOS Today 小部件,在针对 iOS 10 进行测试时,我在小部件标题的右上角看到了“显示更多”/“显示更少”按钮。我怎样才能删除这个按钮?我正在使用 Objective-C。

最佳答案

在iOS 10中,据我所知,show more选项是新的,我们不能删除它,但我们可以根据需要修改它。

以下代码将允许您自动调整 Today 小部件的大小。只需更改表或 Collection View 或您在项目中使用的任何内容。

static CGFloat padding = 25.0;

- (void)viewDidLoad 
{
    [super viewDidLoad];

    // Do any additional setup after loading the view from its nib.

    // This will remove extra separators from tableview
    self.articleTableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];

    // Add the iOS 10 Show More ability
    [self.extensionContext setWidgetLargestAvailableDisplayMode:NCWidgetDisplayModeExpanded];
}

- (void)widgetActiveDisplayModeDidChange:(NCWidgetDisplayMode)activeDisplayMode withMaximumSize:(CGSize)maxSize {
   if (activeDisplayMode == NCWidgetDisplayModeCompact){
       // Changed to compact mode
       self.preferredContentSize = maxSize;
   }
   else{
       // Changed to expanded mode
       self.preferredContentSize = CGSizeMake(self.articleTableView.contentSize.width, self.articleTableView.contentSize.height + padding);
   }
}

关于ios - 从 iOS10 中的 Today 小部件隐藏 "Show More"按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38495833/

相关文章:

ios - 如何在应用程序中显示 apns token ?在 swift 4

ios - 如何消除 Xcode 64 位/32 位警告,或者更好地修复它们?

iphone - 如何更改铃声模式(静音或振动)

iphone - OGL_ES 2.0 : Using multiple texture units vs rebinding textures for separate shaders

objective-c - WebView 中的插件对象被破坏?

ios - 每次移动超过 50 米时,如何使用新位置更新我的代表?

ios - 当我在 iOS 中输入空的 AlertView 文本字段时,不应关闭 AlertViewController

javascript - 事件中的方法

Flutter:如何在textformfield上没有输入时隐藏后缀图标?

flutter - 如何在 flutter 中使用嵌套行/列内的文本溢出?