我写的Appcelerator的模块,这意味着我递给子类的UIView的目的C.继续努力,创造我的视觉控制一个UITableViewControler添加到一个UIView
我想添加一个tableview中有搜索栏,但大多数在线示例使用rootViewController和UITableViewControler。
所以...为了添加一个tableview到当前视图,我需要创建一个tableview和一个UITableViewController并将它们以某种方式添加为当前视图的子视图吗?
我尝试添加其定义为
@interface MainViewController : UITableViewController <UISearchDisplayDelegate, UISearchBarDelegate>
,然后在我看来
#import "MainViewController.h"
- (void)viewDidLoad
{
mainView = [[MainViewController alloc] init];
[self addSubview:mainView.view];
}
-(void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds
{
if(CGRectIsEmpty(self.frame))
{
self.frame = bounds;
[self addSubview:mainView.view];
}
}
一个MainViewController.h & MainViewController.m但它没有工作,我只是得到了一个空视图。有任何想法吗 ?一个示例代码将不胜感激
感谢
你在哪里设置'frame' for'mainView'? – EmptyStack
呃..我没有。我只是使用苹果示例tableSearch(http://developer.apple.com/library/ios/#samplecode/TableSearch/Introduction/Intro.html)中的mainviewcontroller文件,我想如果我在我的视图中运行该表,休息比较容易。我看了,他们没有在这个示例中设置框架 –
看起来,在示例中,mainView是从nib创建的。 '[[MainViewController alloc] initWithNibName:@“MainView”bundle:nil];' – EmptyStack