开发者

How to display my cells textlabel name in my detailtextlabel in iphone

开发者 https://www.devze.com 2023-02-04 12:32 出处:网络
i have created 2 controllers both have tableview in it. when i pop from my second controller to my first controller the cell that i have selected in my second controller to pop to my first controller,

i have created 2 controllers both have tableview in it. when i pop from my second controller to my first controller the cell that i have selected in my second controller to pop to my first controller,the text of that cell should get displayed in the detailtextlabel of my first contr开发者_StackOverflowoller.Can anybody help me in solving this problem


@Abishek if i am clearly understanding your problem you want to take the text that u had selected from your secondView Controller to your detailtextLabel of your firstView controller.....For this i request you to declare a variable in your AppDelegate class

eg:-Let suppose a variable is of NSString type i.e country in the AppDelegate class

In your secondView Controller where you are selecting the text.....give it to

appDelegate.country(appDelegate is a object of AppDelegate class)

Now when you pop to firstView controller ...in cellForRowAtIndexPath give detailtextLabel.text = appDelegate.country you will get the text and choose tableViewtype:UITableViewCellStyleValue2 and in its.

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

   [self.tableView reloadData];
    }

Hope it will work for you!


If you want the cells to display new data, i.e. the textLabel name, you'll have to reload your UITableView.

Assuming you've done all the coding necessary to pass the textLabel name back to the first controller and have this name displayed in a cell, you just need to run:

[yourTableView reloadData];

and all the cells will be refreshed.

0

精彩评论

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

关注公众号