gpt4 book ai didi

iphone - UISegmentedControl`` 在导航项上使 Xcode 崩溃

转载 作者:行者123 更新时间:2023-11-28 22:38:07 32 4
gpt4 key购买 nike

我正在尝试将 UISegmentedControl 放在 Navigation Item 上,但它使我的 xcode 崩溃。我只是在 Interface Builder 中添加了 UISegmentedControl file(IB) 文件,然后在 viewDisAppear

.h

 IBOutlet UISegmentedControl *segmentedControl;

.m

 self.navigationItem.titleView=segmentedControl;

这只会让我的 xcode 因错误而崩溃

2013-03-12 17:38:56.343 Magazine[4728:1dc03] *** Assertion failure in -[UINavigationBar layoutSublayersOfLayer:], /SourceCache/UIKit_Sim/UIKit-2372/UIView.m:5776
2013-03-12 17:38:56.344 Magazine[4728:1dc03] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. UINavigationBar's implementation of -layoutSubviews needs to call super.'
*** First throw call stack:
(0x2854012 0x1ee9e7e 0x2853e78 0x197ff35 0xe819ef 0x1efd6b0 0x7d1fc0 0x7c633c 0x7c6150 0x7440bc 0x745227 0x7458e2 0x281cafe 0x281ca3d 0x27fa7c2 0x27f9f44 0x27f9e1b 0x2d1c7e3 0x2d1c668 0xe3165c 0x2de5 0x2ce5)

libc++abi.dylib:终止调用抛出异常

为什么会出现这个错误

最佳答案

UISegmentedControl * seg1 = [[UISegmentedControl alloc]
initWithItems:[NSArray arrayWithObjects:@"von mir", @"alle", nil]];
[seg1 setSegmentedControlStyle:UISegmentedControlStyleBar];
self.navigationItem.titleView = seg1;

关于iphone - UISegmentedControl`` 在导航项上使 Xcode 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15360934/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com