[HELP] Create view from code for DetailView.

Discussion in 'iOS Programming' started by SmartiOS, Jan 30, 2013.

  1. SmartiOS, Jan 30, 2013
    Last edited by a moderator: Mar 29, 2013

    macrumors newbie

    Jul 13, 2012
    Hi, i'm trying to create a view from code for DetailViewController without using storyboard. so i just need some help here i don't know how it work :confused:

    -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    DetailViewController *detail = [[DetailViewController alloc] init];
    [COLOR="Lime"]// change detailview background color___Changed..OK! //[/COLOR]
    detail.view.backgroundColor = [UIColor whiteColor];
    [COLOR="Lime"] // here i want make uiimage?....doesn't work! //[/COLOR]
    detail.image = UIImage imageNamed:@"cover.png"];
    [COLOR="Lime"] // here i want make UIButton ?....doesn't work///[/COLOR]
    frame = CGRectMake(10, 70, 300, 50); or UIButton something like this...
    [COLOR="Lime"] // make Descriptiontext //[/COLOR]
    [self.navigationController pushViewController:detail animated:YES];
    -	@end
    Thanks for any help.
  2. macrumors 604


    Nov 26, 2007
    Your actual code would be helpful... It's difficult to help you given what you've posted won't even compile.

    What is DetailViewController? What does setting its image property do? What should it do?

    Have you been remembering to add the UI components you create as subviews? They won't appear until you do...
  3. thread starter macrumors newbie

    Jul 13, 2012
    Well, impressive! you don't know what it's DetailViewController? so when you create a push detailsView you will know what's detailviewcontroller, this is one.

    two... i actually want to push different deatilview from selected row and already i did it, but when i access to detailview the background is empty and white screen because i don't use nib file or storyboard.

    once you see that is too difficult, suggest me to a simple method.

    thanks anyway.
  4. macrumors 604


    Nov 26, 2007
    I just double checked, just to be certain. There is definitely not a built in class called DetailViewController. I therefor conclude that it's a class you wrote yourself but didn't share the implementation of. Since you didn't tell us, I have to guess its a subclass of UIViewController. UIViewController doesn't have a property called image. Thus you're either not using a UIViewController as your base class, or you've created a custom property called image.

    No matter how I look at this, you haven't shared enough details about what you are doing. I offered a friendly reminder about what you definitely need to be doing.

    Thanks for the attitude, though. I'm sure everyone online loves helping people with attitude.
  5. macrumors 68030


    Sep 2, 2008
    Put all the code to configure the DetailViewController's view in its viewDidLoad or loadView method.
  6. waterskier2007, Jan 30, 2013
    Last edited by a moderator: Jan 30, 2013

    macrumors 68000


    Jun 19, 2007
    White Lake, MI
    DetailViewController is the class (I believe) that XCode generates for you when you pick a Master>Detail Project from the template browser. Pretty sure it just is a regular view controller with a white view, and it may have a text label on it that says something like "detail view"

Share This Page