iOS 7,UIView子视图是无
问题描述:
为什么在iOS 7中[UIView子视图]总是返回零?iOS 7,UIView子视图是无
我使用这个code,但已经得到了零。
iOS 7中的错误?
编辑:
TWTweetComposeViewController* tweetSheet = [[TWTweetComposeViewController alloc] init];
[tweetSheet setInitialText: twitter_descrp];
[tweetSheet addURL:[NSURL URLWithString: twitter_link]];
NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString: twitter_img]];
UIImage* uiImage = [UIImage imageWithData:imageData];
[tweetSheet addImage:uiImage];
NSLog(@"subviews: %@", [tweetSheet.view firstSubviewOfClass:[UIButton class]]);
这里firstSubviewOfClass从iOS7 Subviews Hierarchy
而一个NSLog的内部得到的是返回此:
subviews: (
)
答
的iOS 7的层次结构发生了很大变化。举一个例子,苹果公司用表格视图和表格视图单元代替了很多UIButton
。
您确定层次结构中确实存在按钮吗?对于调试,您可以尝试拨打
NSLog(@"%@", [tweetSheet.view recursiveDescription]); // (ignore the warning)
以查看视图层次结构的外观。
但是,在iOS 7中,Apple已开始故意阻止访问系统视图(例如UIAlertView
)。有时候是因为安全,有时是因为自己的原因。这意味着您可能无法访问该按钮。
您不应该正在访问该按钮。
它没有。你如何创建你的观点?你能展示一些代码吗? – Fogmeister
你可以把你的代码添加到问题中吗?外部链接可能会下降。 – Amar
@Fogmeister,问题编辑 – CReaTuS