[英]iOS 7, UIView subviews is nil
為什么在iOS 7 [UIView子視圖]中總是返回nil?
我用這代碼 ,但已經得到了零 。
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子視圖層次結構中獲得的
在NSLog內部返回以下內容:
subviews: (
)
iOS 7的層次結構發生了很大變化。 作為一個示例,Apple用表視圖和表視圖單元格替換了許多UIButton
。
您確定層次結構中確實有一個按鈕嗎? 要進行調試,您可以嘗試致電
NSLog(@"%@", [tweetSheet.view recursiveDescription]); // (ignore the warning)
查看視圖層次結構的外觀。
但是,在iOS 7中,Apple已開始有意阻止對系統視圖的訪問(例如UIAlertView
)。 有時是因為安全,有時是因為自己的原因。 這意味着您可能根本無法訪問該按鈕。
您不應該訪問該按鈕。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.