我寫的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