gpt4 book ai didi

iphone - iOS 6.0 上的 MFMessageComposeController 中 UIButton 为 nil

转载 作者:行者123 更新时间:2023-12-03 21:16:08 27 4
gpt4 key购买 nike

我正在尝试打印应用程序的可见和隐藏窗口的 View 层次结构。这是 MFMessageComposeViewController 子类中我的代码的一部分:

NSArray *windows = [[UIApplication sharedApplication] windows];

for(UIWindow *aWindow in windows) {
if([aWindow isMemberOfClass:NSClassFromString(@"UITextEffectsWindow")]) {
sendButton = [self findButtonInView:aWindow];
break;
}
}

findButtonInView: 方法正在当前 UIWindow 中递归搜索 UIButton。

在使用 iOS4.3 和 iOS 5.1 进行测试时,这可以按预期工作(成功找到预期的 UIButton),但不适用于 iOS6。以下是两个测试的 View 层次结构打印结果:

iOS 4.3:

<UITextEffectsWindow: 0x1e32a0; frame = (0 0; 320 480); opaque = NO; layer = <CALayer: 0x1e33d0>>
| <UIPeripheralHostView: 0x1e4a80; frame = (0 224; 320 256); autoresizesSubviews = NO; layer = <UIPeripheralHostLayer: 0x1e4e60>>
| | <UIKeyboardAutomatic: 0x1ad300; frame = (0 40; 320 216); opaque = NO; layer = <CALayer: 0x1ad3b0>>
| | | <UIKeyboardImpl: 0x1ad520; frame = (0 0; 320 216); opaque = NO; layer = <CALayer: 0x1ad6c0>>
| | | | <UIKeyboardLayoutStar: 0x1d47c0; frame = (0 0; 320 216); layer = <CALayer: 0x19ca40>>
| | | | | <UIKBKeyplaneView: 0x1df880; frame = (0 0; 320 216); layer = <CALayer: 0x1df900>>
| | | | | | <UIKBKeyView: 0x1dfe00; frame = (1 119; 40 42); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1dffd0>>
| | | | | | <UIKBKeyView: 0x1e0090; frame = (279 119; 40 42); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1e00e0>>
| | | | | | <UIKBKeyView: 0x1e01e0; frame = (1 173; 38 42); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1e0230>>
| | | | | | <UIKBKeyView: 0x1dbfb0; frame = (41 173; 38 42); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1dc050>>
| | | | | | <UIKBKeyView: 0x1e0330; frame = (81 173; 158 42); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1e0380>>
| | | | | | <UIKBKeyView: 0x1e0440; frame = (241 173; 78 42); opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1e0490>>
| | <CKMessageEntryView: 0x182500; baseClass = UIImageView; frame = (0 0; 320 40); opaque = NO; autoresize = W+TM; layer = <CALayer: 0x1837c0>>
| | | <UIButton: 0x1878c0; frame = (6 8; 26 27); hidden = YES; opaque = NO; autoresize = RM+TM; layer = <CALayer: 0x182e60>>
| | | | <UIImageView: 0x1e56f0; frame = (0 0; 26 27); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1e5720>>
| | | <UIView: 0x184dd0; frame = (7 0; 245 40); autoresize = W+H; userInteractionEnabled = NO; layer = <CALayer: 0x185130>>
| | | <CKContentEntryView: 0x188a50; baseClass = UIScrollView; frame = (6 0; 249 40); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x187230>; contentOffset: {-0, -10}>
| | | | <CKRichContentView: 0x193790; baseClass = UITextContentView; frame = (0 0; 249 20); text = ''; autoresize = W; layer = <CALayer: 0x1938a0>>
| | | | | <UIWebDocumentView: 0xaef200; frame = (0 0; 249 20); text = '
'; opaque = NO; userInteractionEnabled = NO; layer = <UIWebLayer: 0x196c20>>
| | | | | <UITextSelectionView: 0x1a5b60; frame = (0 0; 0 0); userInteractionEnabled = NO; layer = <CALayer: 0x1a5c00>>
| | | | <UIImageView: 0x189fa0; frame = (242 10; 7 20); alpha = 0; opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0x189ff0>>
| | | | <UIImageView: 0x189eb0; frame = (242 23; 7 7); alpha = 0; opaque = NO; autoresize = TM; userInteractionEnabled = NO; layer = <CALayer: 0x189f00>>
| | | <UIImageView: 0x18a190; frame = (7 0; 245 40); opaque = NO; autoresize = W+H; userInteractionEnabled = NO; layer = <CALayer: 0x18a510>>
| | | <UILabel: 0x18a6b0; frame = (245 13; 73 15); text = 'TEST'; clipsToBounds = YES; hidden = YES; opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0x18a720>>
| | | <UIButton: 0x180d00; frame = (252 8; 61 27); opaque = NO; autoresize = LM+TM; layer = <CALayer: 0x184e00>>
| | | | <UIImageView: 0x1ad460; frame = (0 0; 61 27); clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x1ad490>>
| | | | <UIButtonLabel: 0x1871c0; frame = (11 3; 39 20); text = 'Send'; clipsToBounds = YES; opaque = NO; userInteractionEnabled = NO; layer = <CALayer: 0x187280>>

iOS 6.0:

<UIWindow: 0x1fd81f80; frame = (0 0; 320 480); opaque = NO; autoresize = RM+BM; layer = <UIWindowLayer: 0x1fd82080>>
| <UILayoutContainerView: 0x1fd94d50; frame = (0 0; 320 480); autoresize = W+H; layer = <CALayer: 0x1fd94df0>>
| | <UINavigationTransitionView: 0x1fd9a450; frame = (0 0; 320 480); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x1fd9a520>>
| | | <UIViewControllerWrapperView: 0x1fdac9a0; frame = (0 20; 320 460); autoresize = W+H; layer = <CALayer: 0x1fdaca30>>
| | | | <UIView: 0x1fda8cb0; frame = (0 0; 320 460); autoresize = W+H; layer = <CALayer: 0x1fda8c70>>
| | | | | <_UISizeTrackingView: 0x1fda6430; frame = (0 0; 320 460); clipsToBounds = YES; autoresize = W+H; layer = <CALayer: 0x1fda6510>>
| | | | | | <_UIRemoteView: 0x1fda6700; frame = (0 0; 320 480); transform = [0.5, -0, 0, 0.5, -0, 0]; userInteractionEnabled = NO; layer = <CALayerHost: 0x1fda6850>>

我的问题是如何在 UITextEffectsWindow 中找到所需的 UIButton?

iOS6 中的 View 层次结构似乎发生了某种变化...

如果有任何帮助,我将不胜感激。谢谢!

最佳答案

很可能已经改变了。您正在访问 UI 中呈现的未记录的元素,这不能保证在系统更新之间保持一致。如果您想更改 MFMailComposeViewController 类中呈现的 UI 元素的外观,请使用 IUAppearance API。您不应该访问邮件 Controller 类的大部分内容。

Important The mail composition interface itself is not customizable and must not be modified by your application. In addition, after presenting the interface, your application is not allowed to make further changes to the email content. The user may still edit the content using the interface, but programmatic changes are ignored. Thus, you must set the values of content fields before presenting the interface.

关于iphone - iOS 6.0 上的 MFMessageComposeController 中 UIButton 为 nil,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13014143/

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