2
A
回答
4
以編程方式創建一個UIProgressView,它是簡單地使用alloc和初始化,設置幀的事情,添加一個子視圖,就像這樣:
//.h
#import <UIKit/UIKit.h>
@interface ExampleViewController : UIViewController {
//create the ivar
UIProgressView *_progressView;
}
/*I like to back up my iVars with properties. If you aren't using ARC, use retain instead of strong*/
@property (nonatomic, strong) UIProgressView *progressView;
@end
//.m
@implementation
@synthesize progressView = _progressView;
-(void)viewDidLoad {
/* it isn't necessary to create the progressView here, after all you could call this code from any method you wanted to and it would still work*/
//allocate and initialize the progressView with the bar style
self.progressView = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleBar];
//add the progressView to our main view.
[self.view addSubview: self.progressView];
//if you ever want to remove it, call [self.progressView removeFromSuperView];
}
1
大部分的UI元素的創建是這樣的:
UIView *view = [[UIView alloc] initWithFrame:CGRect];
// set the property of the view here
// ...
// finally add your view
[ViewController.view addSubView:view];
相關問題
- 1. 引用以編程方式創建的UI元素
- 2. 如何以編程方式創建指令元素?
- 3. 如何以編程方式創建UIScrollview
- 4. 如何以編程方式創建UIViewController?
- 5. 如何以編程方式創建UIButton
- 6. 如何以編程方式創建NSTextField?
- 7. 如何以編程方式創建Tabbar
- 8. 如何以編程方式創建ProgressBar?
- 9. 如何以編程方式創建CustomCell?
- 10. 如何以編程方式創建NSPopover
- 11. 如何以編程方式創建GPO?
- 12. 如何以編程方式創建NSFetchedPropertyDescription?
- 13. 如何以編程方式創建UIScrollView?
- 14. 如何以編程方式創建TextView?
- 15. 如何以編程方式創建NSSearchField?
- 16. 以編程方式創建SVG錨點元素?
- 17. 以編程方式在jsp中創建輸入表單元素
- 18. 以編程方式創建nativescript-bottom元素
- 19. 使用XML元素以編程方式創建佈局
- 20. 引用以編程方式創建的命名元素?
- 21. 以編程方式創建元素並重新使用代碼
- 22. 如何以編程方式創建20x20px單元網格背景?
- 23. 如何以編程方式使用Win32創建快捷方式
- 24. 如何在Silverlight中以編程方式在畫布中添加UI元素?
- 25. 如何以編程方式導航WPF UI元素選項卡停止?
- 26. 如何以編程方式將UI元素添加到現有的nib文件
- 27. ggplot2 - 以編程方式添加元素
- 28. 如何以編程方式訪問樣式中的元素?
- 29. WPF - 如何以編程方式引用樣式中的元素
- 30. 以編程方式創建流程圖
我不知道你的意思。基於viewController1中的操作,您希望在viewController2出現時顯示進度視圖?如果是這樣,你可以使用viewController2偵聽的通知。收到通知時創建進度視圖。 – 2012-02-29 02:29:51
完全是這樣的...使用通知與使用appDelegate有何不同? – iggy2012 2012-02-29 04:40:59