내 응용 프로그램 루트보기 UINavigationController
의 컨트롤러 내가 만든 클래스 TaskRootController : UIViewController<UITableViewDelegate>
(이보기 jQuery과로 추가가) 등으로 TaskController : UINavigationController
라는 루트 컨트롤러로 시작 내가 응용 프로그램을 시작할 때 제목 양식 TaskRootController 및 배경색을 참조하십시오. 그러나 저는 테이블 뷰를 보지 못합니다. 내 응용 프로그램이 TaskView로 시작하는 경우 rootViewController로 테이블보기를 참조하십시오.는 jQuery과
어떻게하면 테이블보기를 볼 수 있습니까? PS. TaskRootController를 TaskRootController : UITableViewController로 전환하더라도 동작은 동일합니다. 내 코드는 다음과 같습니다 :
AppDelegate.m
@implementation AppDelegate
@synthesize window = _window;
@synthesize taskController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
self.taskController = [TaskController alloc];
self.window.rootViewController = self.taskController;
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
}
- (void)applicationWillTerminate:(UIApplication *)application
{
}
@end
TaskController.m
@implementation TaskController
@synthesize taskRootController;
- (void) pushInboxController
{
TaskBoxController *taskBoxController = [[TaskBoxController alloc] initWithNibName:nil bundle:NULL];
[self pushViewController:taskBoxController animated:YES];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
[self.navigationBar setBarStyle: UIBarStyleBlack];
[self.navigationBar setTranslucent: NO];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.taskRootController = [[TaskRootController alloc] initWithNibName:nil bundle:NULL];
UIViewController *root = self.taskRootController;
[self initWithRootViewController: root];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear: animated];
[self performSelector:@selector(pushInboxController)];
}
@end
TaskRootController.m
@implementation TaskRootController
@synthesize taskRootView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
NSLog(@"DUPA");
NSLog(@"SIZE x:%f,y:%f ; %f:%f", self.view.bounds.origin.x, self.view.bounds.origin.y, self.view.bounds.size.width, self.view.bounds.size.height);
self.view.backgroundColor = [UIColor grayColor];
self.title = @"Root";
self.taskRootView = [[UITableView alloc] initWithFrame: CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height) style:UITableViewStyleGrouped];
self.taskRootView.delegate = self;
self.taskRootView.dataSource = self;
[self.view addSubview:self.taskRootView];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
// Return the number of sections.
return 1; // put number for section.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return 6; // put number as you want row in section.
}
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
CGFloat result = 20.0f;
if([tableView isEqual:self.taskRootView])
{
result = 40.0f;
}
return result;
}
@end
왜이 self.taskRootController =에서 "무기 호"로 펜촉 이름을 않았다 [[TaskRootController의 ALLOC] initWithNibName : 무기 호 번들 : NULL]; –
xib 파일이 없기 때문에 – lukisp
ok, 다음과 같이 taskController를 지정하십시오. self.taskController = [[TaskController alloc] init]; 대신에 self.taskController = [TaskController alloc]; –