2011-04-19 53 views
0

我在使用CCUIViewWrapper時無法定位UITextView。無論我如何設置位置,總是會在屏幕的左上角結束。CCUIViewWrapper忽略UITextView的位置

我都試圖設置在的UITextView(initWithFrame的初始化位置:CGRectMake(500,500,200,200),並通過改變所述包裝本身的位置

的大小設置爲包裝似乎在任何時候(即我初始化UITextView的大小被忽略)的兌現

在正確的方向任何幫助將是巨大的

我的代碼如下所示:!

UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(500, 500, 200, 200)]; 
textView.backgroundColor = [UIColor lightGrayColor]; 
textView.textColor = [UIColor whiteColor]; 
textView.text = text; 
[textView setEditable:NO]; 

CCUIViewWrapper* wrapper = [CCUIViewWrapper wrapperForUIView:textView]; 
wrapper setPosition: CGPointMake(200, 200)]; 
wrapper.contentSize = CGSizeMake(50, 50); 
[self addChild:wrapper]; 

這導致了大小50×50的一個TextView和位於左上角...

CCUIViewWrapper在GitHub上: https://github.com/splhack/CCUIViewWrapper

回答

0

嘗試:

UITextView *textView = [[UITextView alloc] init]; 
textView.backgroundColor = [UIColor lightGrayColor]; 
textView.textColor = [UIColor whiteColor]; 
textView.text = text; 
[textView setEditable:NO]; 

CCUIViewWrapper* wrapper = [CCUIViewWrapper wrapperForUIView:textView]; 
wrapper.contentSize = CGSizeMake(50, 50); 
wrapper.position = ccp(200,200); 
[self addChild:wrapper]; 
+0

還檢查了[這提問](http://stackoverflow.com/questions/3857925/anchorpoint-issues-with-ccuiviewwrapper/8003011#8003011)。這是關於改變錨點,可能有助於解決一些定位問題。 – Shikima 2011-11-04 15:02:55