Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

"Problems with View1 path to View2."

pleasehelppleasehelp Posts: 7New Users
edited September 2011 in iPhone SDK Development
hi friends,

hope you can help.

i have a string (customerName) in CustomersViewController (view 1).
now i just want to display in my CustomersViewDetailController (view 2)
the string (customerName) from CustomersViewController (view 1). this should be displayed in the section 0 of my tableview.

it must be something little but i don´t know how to do!?

in my CustomersViewController.m


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSInteger row = [indexPath row];
NSString *customerName = @"Name";
if (cusDetailViewController == nil) {
CustomersDetailViewController *aCustomerDetail = [[CustomersDetailViewController alloc] initWithNibName:@"CustomersDetailView" bundle:nil];
self.cusDetailViewController = aCustomerDetail;
[aCustomerDetail release];
}
CustomersDetailViewController *cusDetailViewController = [[CustomersDetailViewController alloc] initWithStyle:UITableViewStyleGrouped];
[self.navigationController pushViewController:cusDetailViewController animated:YES];
if(indexPath.section == 0)
{
<----Here I dont' t know what to do---->
}
[cusDetailViewController release];
cusDetailViewController = nil;
}
Post edited by pleasehelp on

Replies

  • DrBeak1DrBeak1 Posts: 298Registered Users
    edited September 2011
    Hmm... well it looks like for one you are alloc/init CustomersDetailViewController two times.
    Once here:

    if (cusDetailViewController == nil) {
    CustomersDetailViewController *aCustomerDetail = [[CustomersDetailViewController alloc] initWithNibName:@\"CustomersDetailView\" bundle:nil];
    self.cusDetailViewController = aCustomerDetail;
    [aCustomerDetail release];
    }

    and again here:

    CustomersDetailViewController *cusDetailViewController = [[CustomersDetailViewController alloc] initWithStyle:UITableViewStyleGrouped];

    You only need to do this once. If you are doing it twice just so you can indicate both to use your .xib and that you want the UIViewController to be of type UITableViewStyleGrouped, I would go with indicating the .xib file and set the style in interface builder. Also you should not set cusDetailViewController to nil in the method but in the dealloc method (unless you are using xcode 4, which does this for you).

    Lastly, to set the cell.textLabel in cusDetailViewController, you need to pass "name" to this new viewController in some way (possibly NSUserDefaults) and then set it as the textLabel.text of the cell in either cellForRowAtIndexPath or willDisplayCell.
Sign In or Register to comment.