我试图了解uitable视图并实现它并能够从nsArray中将数据填充到行中。我已经创建了一个NextViewController,它包含一个动态标签,它将从SimpleTable类接收inpur / text。对于ex, 在简单的表视图类中,我有包含内容的行(请参阅代码):
**My SimpleViewController.m**
#import "SimpleTableViewController.h"
#import "NextViewController.h"
@implementation SimpleTableViewController
- (void)viewDidLoad {
arryData = [[NSArray alloc] initWithObjects:@"iPhone",@"iPod",@"MacBook",@"MacBook Pro",nil];
self.title = @"Simple Table Exmaple";/**/NOT ABLE TO SET TITLE.WHY?????Please guide how to use NSlog here**
[super viewDidLoad];
}
***//And on selection of any row i want to navigate to next view controller class***
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NextViewController *nextController = [[NextViewController alloc] initWithNibName:@"NextViewController" bundle:nil];
[self.navigationController pushViewController:nextController animated:YES];
[nextController changeProductText:[arryData objectAtIndex:indexPath.row]];
}
@end
**My NextViewController.h**
@interface NextViewController : UIViewController {
IBOutlet UILabel *lblProductTxt;
}
- (IBAction) changeProductText:(NSString *)str;
@end
**my NextViewController.m**
//posted only important part of code where i feel may be an issue
- (IBAction) changeProductText:(NSString *)str{
lblProductTxt.text = str;
} @end
我已经正确检查了IB并且连接正确。请帮助我。没有得到我错的地方?
答案 0 :(得分:0)
确保self.navigationController具有有效值。在pushViewController调用之前添加它:
NSLog(@" self.navigationController 0x%x", self.navigationController);