ios - 如何在 UIScrollView 中添加多个 UIView
<p><p>我有一个绘制饼图的 UIView,我想以编程方式在 UIScrollView 中放置 3 个或 4 个图表。我该怎么做?</p>
<p>我的h文件是这样的</p>
<pre><code>@class PieChart;
@interface ViewController : UIViewController {
}
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
</code></pre>
<p>和m文件</p>
<pre><code>- (void)viewDidLoad
{
;
];
;
scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
scrollView.clipsToBounds = YES;
scrollView.scrollEnabled = YES;
scrollView.pagingEnabled = YES;
PieChart *chart = [initWithFrame:CGRectZero];
;
;
}
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>如果需要给 View 添加 subview ,需要使用<code></code>。这是常见的做法。
阅读框架和边界( View 和 subview 的坐标系):</p>
<ul>
<li> <a href="https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaViewsGuide/Coordinates/Coordinates.html" rel="noreferrer noopener nofollow">https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaViewsGuide/Coordinates/Coordinates.html</a> </li>
</ul>
<p>据我了解,由于 ScrollView 的内容大小,您遇到了问题。在这里阅读更多:</p>
<ul>
<li> <a href="http://developer.apple.com/library/ios/#DOCUMENTATION/WindowsViews/Conceptual/UIScrollView_pg/Introduction/Introduction.html" rel="noreferrer noopener nofollow">http://developer.apple.com/library/ios/#DOCUMENTATION/WindowsViews/Conceptual/UIScrollView_pg/Introduction/Introduction.html</a> </li>
</ul>
<p>希望对你有帮助。</p></p>
<p style="font-size: 20px;">关于ios - 如何在 UIScrollView 中添加多个 UIView,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/11830536/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/11830536/
</a>
</p>
页:
[1]