小编Zap*_*ndr的帖子

奇怪的UIView-Encapsulated-Layout-Height错误

我正在制作测试应用程序,所以在我的tableviewCell故事板中我有imageView和webView(用于显示html文本).我为imageView设置了top/left/right/height = 200的约束,它们之间的间距= 5,webView的左/右/ bot,所以我想以编程方式计算我的webView高度,然后更改单元格的高度来拉伸我的webView.但我得到了这个:

无法同时满足约束.

可能至少下列列表中的一个约束是您不想要的约束.

试试这个:

(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints & fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property

translatesAutoresizingMaskIntoConstraints) 
(
    "<NSLayoutConstraint:0x7fd6f3773f90 V:[UIImageView:0x7fd6f3773e90(200)]>",
    "<NSLayoutConstraint:0x7fd6f3774280 UIImageView:0x7fd6f3773e90.top == UITableViewCellContentView:0x7fd6f3462710.topMargin>",
    "<NSLayoutConstraint:0x7fd6f3774320 V:[UIImageView:0x7fd6f3773e90]-(5)-[UIWebView:0x7fd6f3462800]>",
    "<NSLayoutConstraint:0x7fd6f3774370 UITableViewCellContentView:0x7fd6f3462710.bottomMargin == UIWebView:0x7fd6f3462800.bottom>",
    "<NSLayoutConstraint:0x7fd6f375ee40 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fd6f3462710(205)]>"
)
Run Code Online (Sandbox Code Playgroud)

有什么建议?

constraints objective-c webview uitableview ios

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

"还创建xib文件"按钮被禁用

我有创建UIView's子类的问题.例如,创建UIViewControllers或者UITableViewCells没有问题.

为什么会这样?

UIView按钮被禁用 UIViewController没问题

我使用cmd+N和Xcode版本7.3.1 创建视图:新文件

xcode xib uiview ios

16
推荐指数
2
解决办法
3683
查看次数

如何防止现有模态的活动控制器?

我们有2个控制器:MainVC和ProfileVC.从MainVC我们profileButton按下ProfileDC (导航栏上的左侧项目).

在Profile VC中,导航栏上有2个按钮:返回main(leftItem)并打开alertView(rightItem).

所以有简单的KIF测试(导航栏上只有永久的左右点击):

- (void)testProfileButtons
    {
        [tester waitForAnimationsToFinishWithTimeout:0.3];
        while (true)
        {
            [tester tapScreenAtPoint:CGPointMake(20, 20)];
            [tester waitForTimeInterval:0.1];
            [tester tapScreenAtPoint:CGPointMake(380, 20)];
            [tester waitForTimeInterval:0.1];
            [tester tapScreenAtPoint:CGPointMake(20, 20)];
            [tester waitForTimeInterval:0.1];
        }
    }
Run Code Online (Sandbox Code Playgroud)

它崩溃了应用程序错误:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller <UINavigationController: 0x7fe862ef82d0>.'

*** First throw call stack:
(
    0   CoreFoundation                      0x0000000110944c65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x00000001105dabb7 objc_exception_throw + 45
    2   UIKit                               0x000000010f44b80d -[UIViewController _presentViewController:withAnimationController:completion:] + 3238
    3   UIKit                               0x000000010f44d6c1 …
Run Code Online (Sandbox Code Playgroud)

objective-c presentmodalviewcontroller ios

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

如何绑定Realm对象的变化?

在我的项目中我试图通过MVVM工作,所以在虚拟机.h文件中

  @property (nonatomic, strong) NSArray    *cities;
Run Code Online (Sandbox Code Playgroud)

.m文件中

  - (NSArray *)cities {
        return [[GPCity allObjects] valueForKey:@"name"];
    }
Run Code Online (Sandbox Code Playgroud)

GPCity是一个RLMObject子类如何通过ReactiveCocoa绑定它(我的意思是看所有城市更新/添加/删除)?

就像是:

RAC(self, cities) = [[GPCity allObjects] map:(GPCity *)city {return city.name;}];
Run Code Online (Sandbox Code Playgroud)

mvvm realm ios reactive-cocoa

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

根据宽高比缩放视频视图

我想在不同屏幕尺寸的设备上缩放视频流。发送者的视频大小也可能不同。

到目前为止我所拥有的代码:

public func videoView(_ videoView: RTCEAGLVideoView, didChangeVideoSize size: CGSize) {
        // scale by height
        let w = renderer.bounds.height * size.width / size.height
        let h = renderer.bounds.height
        let x = (w - renderer.bounds.width) / 2
        renderer.frame = CGRect(x: -x, y: 0, width: w, height: h)
    }
Run Code Online (Sandbox Code Playgroud)

渲染器是渲染视频的视图。它可以缩放,但方式不正确。视频有些部分丢失了,高度还好。但宽度被裁剪成我所理解的。

是否有可能实现一种在不损失宽高比的情况下全屏显示视频(在接收端)的解决方案?

ios webrtc swift

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

NSAttributedString冻结UITableView

使用NSAttributedString滚动时应用程序确实冻结(当我使用NSString它工作正常),所以有我的方法:

- (void)setSubtitleForCell:(TTTableViewCell *)cell item:(TTPhotoPost *)item
{
    NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData:
                                            [item.caption dataUsingEncoding:NSUnicodeStringEncoding]
                                                                            options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType }
                                                                 documentAttributes:nil
                                                                              error:nil];

    [cell.descriptionLabel setAttributedText:attributedString];
}
Run Code Online (Sandbox Code Playgroud)

那里有什么错误吗?或某种方式使att.string更快?

objective-c uitableview nsattributedstring ios

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