我正在開發iOS 5應用程序。我想使用它的默認視圖以編程方式調整UIView大小。這是視圖命名爲cardView。UILabel和UIView返回viewDidAppear上的大小(0,0)
@interface ThreeCardsViewController : UIViewController
{
...
IBOutlet UIView* cardView;
...
}
@property (nonatomic, retain) IBOutlet UIView* cardView;
...
當我向viewDidAppear
中的方法發送消息時,我得到的cardView大小爲0x0。
@implementation ThreeCardsViewController
...
@synthesize cardView;
...
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self setUpViews];
}
- (void) setUpViews
{
...
futureCardState.cardViewY =
[self computeDescriptionViewPosWith:futureCardState.cardViewSize];
...
[self showCard:pastCardState];
}
- (CGFloat) computeDescriptionViewPosWith:(CGSize)newDescriptionViewSize
{
CGFloat newY;
newY = cardView.frame.size.height - newDescriptionViewSize.height;
return newY;
}
所有視圖,或uilabels具有大小(0,0)。
我敢肯定,這個看法與廈門國際銀行連接,使用Interface Builder
你知道爲什麼我得到(0,0)?我在哪裏可以做這個初始化?
向我們展示'setUpView'的代碼。另外,確保你總是調用'super'的'viewDidAppear:'。 – mattjgalloway 2011-12-23 10:07:12
你合成cardView嗎? – Maulik 2011-12-23 10:10:51
我用新的細節更新了我的問題。 @mattjgalloway,我已經添加了[super viewDidAppear:...],但它還沒有工作。 – VansFannel 2011-12-23 10:24:27