TwUI
,它从UIKit获得了很多,但它在Mac上.这就是我为iOS和iPad标记的原因.苹果电脑.所以,我创建了一个视图,底部需要有40px的边距,无论窗口的垂直大小有多大.出于多种原因,我不允许窗口水平扩展.这是我正在谈论的样本的样子.抱歉丑陋的外表,我只是使用示例视图进行测试. 好吧,所以看到底部40px的黑色空间?
我正在通过这样的方式创建红色视图:
CGRect b = self.vIEw.bounds;b.origin.y += TAB_HEIGHT; //40pxb.size.height -= TAB_HEIGHT;
然后我用该框架创建视图.
但是,一旦我尝试在红色视图上添加自动调整遮罩,它就会失去底部40px,并且只填充整个视图.对于那些不熟悉TwUI的人来说,自动调整样本掩码如下所示:
vIEw.autoresizingMask = TUIVIEwautoresizingFlexibleHeight;
因此,自动调整面具采用iOS对应物.但是,设置该掩码会执行此 *** 作:
所以我的问题是,如何在这个视图的底部保留一个余量?
解决方法 @Rob,我可以毫不费力地自动化它.下面的代码是我使用TwUI github trunk修改了一个空项目.
- (voID)applicationDIDFinishLaunching:(NSNotification *)aNotification{ // Insert code here to initialize your application TUINSVIEw *content = [[TUINSVIEw alloc] initWithFrame:CGRectZero]; CGRect b = [window frame]; b.origin = CGPointZero; content.frame = b; [window setContentVIEw:content]; TUIVIEw *vIEwA = [[TUIVIEw alloc] initWithFrame:CGRectZero]; vIEwA.frame = content.bounds; vIEwA.backgroundcolor = [TUIcolor blackcolor]; [content setRootVIEw:vIEwA]; vIEwA.autoresizingMask = TUIVIEwautoresizingFlexibleSize; TUIVIEw *vIEwB = [[TUIVIEw alloc] initWithFrame:CGRectZero]; vIEwB.backgroundcolor = [TUIcolor redcolor]; b = vIEwA.bounds; b.origin.y+=30; b.size.height-=30; vIEwB.frame = b; [vIEwA addSubvIEw:vIEwB]; vIEwB.autoresizingMask = TUIVIEwautoresizingFlexibleSize;}
编辑:
我像这样编写了我的TUIVIEwController的loadVIEw,它到目前为止工作得很好.
- loadVIEw { TUIVIEw *v = [[TUIVIEw alloc] initWithFrame:CGRectMake(0,320,480)]; tableVIEw = [[TUItableVIEw alloc] initWithFrame:v.bounds style:TUItableVIEwStylePlain]; [tableVIEw scrollTotopAnimated:NO]; tableVIEw.autoresizingMask = TUIVIEwautoresizingFlexibleSize; document = [[BBSDocdocument alloc] init]; tableVIEw.delegate = self; tableVIEw.dataSource = self; CGRect rect = [v bounds]; [v addSubvIEw:tableVIEw]; [self setVIEw:v];}
编辑2:
我的代码与TUIVIEwController子类:
//TestVC.h:#import <Foundation/Foundation.h>#import "TUIKit.h"@interface TestVC : TUIVIEwController {@private TUIVIEw *vIEwA;}- (ID)initWithNibname:(Nsstring *)nibnameOrNil bundle:(NSBundle *)nibBundleOrNil;@end//TestVC.m@implementation TestVC- (ID)initWithNibname:(Nsstring *)nibnameOrNil bundle:(NSBundle *)nibBundleOrNil{ self = [super initWithNibname:nil bundle:nil]; if (self) { // Initialization code here. } return self;}- (voID)loadVIEw { self.vIEw = [[[TUIVIEw alloc] initWithFrame:CGRectZero] autorelease]; self.vIEw.autoresizingMask = TUIVIEwautoresizingFlexibleSize;}//application delegate:- (voID)applicationDIDFinishLaunching:(NSNotification *)aNotification{ // Insert code here to initialize your application TUINSVIEw *content = [[TUINSVIEw alloc] initWithFrame:CGRectZero]; CGRect b = [window frame]; b.origin = CGPointZero; content.frame = b; [window setContentVIEw:content]; TUIVIEw *vIEwA = [[TUIVIEw alloc] initWithFrame:CGRectZero]; vIEwA.frame = content.bounds; vIEwA.backgroundcolor = [TUIcolor blackcolor]; [content setRootVIEw:vIEwA]; [vIEwA setautoresizingMask:TUIVIEwautoresizingFlexibleSize]; TUIVIEw *vIEwB = [[TUIVIEw alloc] initWithFrame:CGRectZero]; vIEwB.backgroundcolor = [TUIcolor redcolor]; b = vIEwA.bounds; b.origin.y+=30; b.size.height-=30; vIEwB.frame = b; [vIEwA addSubvIEw:vIEwB]; vIEwB.autoresizingMask = TUIVIEwautoresizingFlexibleSize; TestVC *testVC = [[TestVC alloc] initWithNibname:nil bundle:nil]; testVC.vIEw.frame = vIEwB.bounds; testVC.vIEw.backgroundcolor = [TUIcolor yellowcolor]; [vIEwB addSubvIEw:testVC.vIEw];}总结
以上是内存溢出为你收集整理的objective-c – 在TwUI中找出自动调整掩码 – 底部边距?全部内容,希望文章能够帮你解决objective-c – 在TwUI中找出自动调整掩码 – 底部边距?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)