Loading problem of NIB file from TabViewController in iPhone
I have a UITableViewController (MyViewController.xib). This is showing 3 rows with their title. I have 3 new xib file for each row title.On each row selection I want to load XIB file. I am getting the place when I am clicking on RowIndex Selection. But when i am trying to load NIB file nothing is happening. I mean nither program is being crashed nor NIB file is being load.
I am defining my interface declaration here.
#import <UIKit/UIKit.h>
#import "HistoryShow.h"
@interface MyViewController : UITableViewController {
NSArray *tableList;
IBOutlet HistoryShow *historyController;
}
@property (nonatomic,retain) NSArray *tableList;
@property (nonatomic,retain) IBOutlet HistoryShow 开发者_Go百科*historyController;
@end
My implementation details are below.
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *str = [NSString stringWithFormat:@"%@",[tableList objectAtIndex:indexPath.row]]; //typecasting
if([@"History" isEqual:str])
{
NSLog(@"!!!!!!!!!!!!!!!");
HistoryShow *detailViewController = [[[HistoryShow alloc]initWithNibName:@"HistoryShow" bundle:nil]autorelease];
[historyController release];
}
}
This is prining "!!!!!!" on console but next "HistoryShow.xib" is not being load.
What is the exact problem ? Thanks in advance.
You have to add the view to your present view using addSubview:
or push the viewController
using a navigationController
to see the view.
Something like this
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *str = [NSString stringWithFormat:@"%@",[tableList objectAtIndex:indexPath.row]]; //typecasting
if([@"History" isEqual:str])
{
NSLog(@"!!!!!!!!!!!!!!!");
HistoryShow *detailViewController = [[HistoryShow alloc]initWithNibName:@"HistoryShow" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES]; // if you have a navigation controller
[detailViewController release];
}
}
You are instantiating detailViewController
, but you aren't doing anything with it.
Try adding this after the alloc
of detailViewController
:
[self presentModalViewController:detailViewController animated:YES];
精彩评论