开发者

Not Able to set title and Navigate to the next view by clicking on corresponding row in uitableview

i tried to understand the uitable view and implemented it and able to populate data into row from a nsArray.I have make a NextViewController consisting of a dynamic lable which will receive开发者_运维百科 inpur/text from the SimpleTable class.For ex, in simple table view class i have rows with content as(see code please):

**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  

I have check IB properly and the connections are proper.Please help me.Not getting where i am wrong?


Make sure self.navigationController has a valid value. Add this before the pushViewController call:

  NSLog(@" self.navigationController  0x%x", self.navigationController);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜