Maximum height of iOS 8 Today Extension?

后端 未结 5 775
醉话见心
醉话见心 2020-12-23 09:56

I am working on a Today Extension with a dynamically sized table. I have been able to get the table to resize for the content using:

    self.preferredConten         


        
5条回答
  •  我在风中等你
    2020-12-23 10:42

    It seems, that iOS is adding an UIView-Encapsulated-Layout-Height constraint to your own constraints:

    (
        "",
        "",
        "<_UILayoutSupportConstraint:0x6100002a2f40 V:[_UILayoutGuide:0x7f92d0513810(0)]>",
        "<_UILayoutSupportConstraint:0x6100002a2ee0 V:|-(0)-[_UILayoutGuide:0x7f92d0513810]   (Names: '|':UIView:0x7f92d040c810 )>",
        "<_UILayoutSupportConstraint:0x6100002a3000 V:[_UILayoutGuide:0x7f92d0515100(0)]>",
        "<_UILayoutSupportConstraint:0x6100002a2fa0 _UILayoutGuide:0x7f92d0515100.bottom == UIView:0x7f92d040c810.bottom>",
        ""
    )
    

    This constraint forces the widget to have the maximum height. You can get it's value like this:

    - (void)widgetPerformUpdateWithCompletionHandler:(void (^)(NCUpdateResult))completionHandler {
    
        for (NSLayoutConstraint *constraint in self.view.constraints) {
            if ([constraint.identifier isEqualToString:@"UIView-Encapsulated-Layout-Height"]) {
                NSLog(@"Height: %@", @(constraint.constant));
            }
        }
    
        completionHandler(NCUpdateResultNewData);
    }
    

提交回复
热议问题