Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7940463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:23:45+00:00 2026-06-03T23:23:45+00:00

I’m new to iOS and Objective-C. I have an application that displays a table

  • 0

I’m new to iOS and Objective-C. I have an application that displays a table view, and opens a new view when click the user clicks on a row.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {  
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    DetailViewController *detailController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];
    [detailController changeSubjectText:[subject_data_Array objectAtIndex:indexPath.row]];

    //navigationController = [[UINavigationController alloc] initWithRootViewController:detailController];

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [self.window addSubview:navigationController.view];
    [self.window makeKeyAndVisible];
}

In my detail view I have coded:

-(IBAction)closeDetail:(id)sender {
    NSLog(@"closeDetail");
    [self.view removeFromSuperview];
}

But it’s not working. Can anyone help?


Can anyone help me?

how i can close view?

download my code in –> http://www.vasuta.com/ios/multiview2.zip

open build and run click one row in “Bulletin Board” DetailView it’s open click Close …..

why DetailView is not full screen and why can’t close detail view?

i open it wrong or i close it wrong

help me please

didSelectRowAtIndexPath you can see in “GadgetBulletinsTVContoller.m” and close command you can see in “DetailViewController.m”

Thank you very much

ps. sorry for my english skill 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:23:47+00:00Added an answer on June 3, 2026 at 11:23 pm

    Why are you creating that window object and why are you trying to add your subview to it?
    if you want to add a subview you should add it to the parent, the tableview or the parent of the tableView.

    a better idea would be to push a new view controller on the stack that would display the info you want to show.

    Here is a tutorial that shows how to push a new view controller when selecting a cell in a tableview tutorial link .

    EDIT:
    in MultipleAppDelegate – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions should look like below:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.
        self.viewController = [[MultipleViewController alloc] initWithNibName:@"MultipleViewController" bundle:nil];
        UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.viewController];
        navController.navigationBarHidden = YES;
        self.window.rootViewController = navController;
    
        [self.window makeKeyAndVisible];
        return YES;
    }
    

    In GadgetBulletinsTVContoller.h declare a protocol like below:

    @protocol GadgetBulletinsTVControllerDelegate <NSObject>
    @optional
    - (void)showItemDetails:(id)selectedItem;
    
    @end
    

    and a delegate property:

    @property (nonatomic, assign)id<GadgetBulletinsTVControllerDelegate>delegate;
    

    In GadgetBulletinsTVContoller.m synthesize the delegate.
    – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    should look like this:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
    {   
        [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
        if([delegate respondsToSelector:@selector(showItemDetails:)])
        {
            [delegate showItemDetails:[subject_data_Array objectAtIndex:indexPath.row]];
        }
    }
    

    In FirstViewController.m tell the controller to implement the GadgetBulletinsTVControllerDelegate like this:

        @interface FirstViewController ()<GadgetBulletinsTVControllerDelegate>
    
    in viewDidLoad method tell the gadgetBulletinsController that his delegate is the FirstViewController class, like this:
    
    if (gadgetBulletinsContoller == nil) {
            gadgetBulletinsContoller = [[GadgetBulletinsTVContoller alloc] init];
            gadgetBulletinsContoller.delegate = self;
        }  
    

    and implement the GadgetBulletinsTVControllerDelegate’s methods:

    - (void)showItemDetails:(id)selectedItem
    {
        if([delegate respondsToSelector:@selector(showDetailsScreenForItem:)])
        {
            [delegate showDetailsScreenForItem:selectedItem];
        }
    }
    

    In FirstViewController.h declare a protocol like below:

    @protocol FirstViewControllerDelegate <NSObject>
    
    - (void)showDetailsScreenForItem:(id)item;
    
    @end
    

    and declare a delegate property like below(don’t forget to synthesize in .m file):

    @property (nonatomic, assign)IBOutlet id<FirstViewControllerDelegate>delegate;
    

    In MultipleViewController.xib select the FirstViewController screen and in outlets drag from the delegate to the fileOwner for setting the value of the delegate to the MultipleViewController(you can do this in code if you want to).

    In MultipleViewController.m tell the MultipleViewController to implement the FirstViewControllerDelegate protocol like below:

    @interface MultipleViewController ()<FirstViewControllerDelegate>
    

    and implement the protocol method:

    - (void)showDetailsScreenForItem:(id)item
    {
        DetailViewController *detailController = [[DetailViewController alloc] initWithNibName:@"DetailView" bundle:nil];
        [detailController changeSubjectText:item];
        [self.navigationController pushViewController:detailController animated:YES];
    }
    

    In DetailViewController modify the closeDetail method to look like this:

    - (IBAction)closeDetail:(id)sender {
        NSLog(@"closeDetail");
        [self.navigationController popViewControllerAnimated:YES];
    }
    

    and voila, Your GadgetBulletinsTVController items details are pushed. You need to do the same steps for the other controllers from where you want to show details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I've got a string that has curly quotes in it. I'd like to replace
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I am doing a simple coin flipping experiment for class that involves flipping a
I have this code to decode numeric html entities to the UTF8 equivalent character.
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.