1.UITabBar
@interface MDTabBarView : UIView <UITabBarDelegate>{
}
#define SYSTABBARITEM(TITLE, INAME, TAG) [[[UITabBarItem alloc] initWithTitle:TITLE image:[[LoaderImage shared] imageNamed:INAME] tag:TAG] autorelease]
UITabBar *tabbar = [[UITabBar alloc] initWithFrame:CGRectMake(0.0,0.0, self.bounds.size.width, 49.0)];
CGRect tb_size = [ UIScreen mainScreen ].applicationFrame;
self.center = CGPointMake(tb_size.size.width/2, tb_size.size.height-24.5f);
tabbar.delegate = self;
tabbar.userInteractionEnabled = YES;
NSMutableArray *tbitems = [NSMutableArray array];
[tbitems addObject:SYSTABBARITEM(@"阅读", @"23-bird.png", 0)];
[[tbitems objectAtIndex:0] setAction:@selector(toolsAction:)]; //添加按钮事件
tabbar.items = tbitems;
tabbar.selectedItem = [tbitems objectAtIndex:0]; //设置默认选中项
[self addSubview:tabbar];
2.UITableView
@interface MDDirView : UITableView <UITableViewDelegate, UITableViewDataSource> {
}
- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
self = [super initWithFrame:frame style:style];
//指定了下面的两个委托的协议后,就可能像使用uitableviewController一下使用自定义的uitableview了
[self setDelegate:self];
[self setDataSource:self];
return self;
}