Simple Brochure App

Discussion in 'iOS Programming' started by Waragainstsleep, Nov 24, 2011.

  1. Waragainstsleep macrumors regular

    Joined:
    Oct 15, 2003
    Location:
    UK
    #1
    Hi all,

    I am building a very simple brochure app for the iPhone (planning on adding the iPad bit later).

    I have created a front page (root view controller) with a button which links to a second page/view controller. You can swipe the second page left to return to the front page. When I did this bit it all worked fine and I could go back and forth between both pages happily.

    I figured it would be a simple matter to add more buttons to the front page and link them the same way to other pages. I have added two more buttons and two more pages and while I can get to those pages in the iOS simulator, I cannot then swipe back to the front page from page 3 or page 4. I have to quit the simulator to fix the crash. Page 2 still works fine, and apart from the images, page 3 and 4 are set up identically to page 2.

    I followed this video tutorial on Youtube to build the first two pages:

    http://www.youtube.com/watch?v=It2fAolaFV0&feature=related


    There are no links directly between pages 2,3 and 4. Everything goes through the front page.

    Does anyone know why this would crash?
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    You will need to provide more information. At the moment the reason could literally be anything. What is the exact (copy and past it) message when it crashes. Is the debugger invoked? If so on which line? What does your code look like (post it)?
     
  3. Waragainstsleep thread starter macrumors regular

    Joined:
    Oct 15, 2003
    Location:
    UK
    #3
    The app actually hangs. Or maybe it doesn't hang, but I can't get back from either of the additional pages I added. If I quit the app on the simulator then relaunch, then it crashes. I just get a black screen.

    GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 8 20:32:45 UTC 2011)
    Copyright 2004 Free Software Foundation, Inc.
    GDB is free software, covered by the GNU General Public License, and you are
    welcome to change it and/or distribute copies of it under certain conditions.
    Type "show copying" to see the conditions.
    There is absolutely no warranty for GDB. Type "show warranty" for details.
    This GDB was configured as "x86_64-apple-darwin".Attaching to process 2967.
    sharedlibrary apply-load-rules all
    Current language: auto; currently objective-c
    (gdb)

    ----------

    I haven't typed a single word of code yet myself but here is some:
    Code:
    
    //
    //  ViewController.m
    //  RYL
    //
    //  Created by Waragainstsleep on 21/11/2011.
    //  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
    //
    
    #import "ViewController.h"
    
    @implementation ViewController
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Release any cached data, images, etc that aren't in use.
    }
    
    #pragma mark - View lifecycle
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
    	// Do any additional setup after loading the view, typically from a nib.
    }
    
    - (void)viewDidUnload
    {
        [super viewDidUnload];
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
    }
    
    - (void)viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear:animated];
    }
    
    - (void)viewDidAppear:(BOOL)animated
    {
        [super viewDidAppear:animated];
    }
    
    - (void)viewWillDisappear:(BOOL)animated
    {
    	[super viewWillDisappear:animated];
    }
    
    - (void)viewDidDisappear:(BOOL)animated
    {
    	[super viewDidDisappear:animated];
    }
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        // Return YES for supported orientations
        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
            return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
        } else {
            return YES;
        }
    }
    
    @end
    
    
     
  4. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    What have you done to debug? Have you enabled a breakpoint in your code to try and find out what's happening? What does the code look like?
     
  5. Waragainstsleep thread starter macrumors regular

    Joined:
    Oct 15, 2003
    Location:
    UK
    #5
    Thanks for the reply.

    I'm not a programmer, I have no idea what I'm doing with code. Never really got much past 'Hello World" in java years ago.

    All of this was done from the Storyboard view in Xcode 4.2. I followed the video tutorial I posted from youtube which showed how to make a page with a button that switched you to another page, then you could swipe to go back to page 1.

    I then repeated the process to create two other pages linked to two more buttons on page one but I am unable to return to page 1 from either of my two new pages. They look identical to page 2 as far as I can see, each page simply has a different image on it.

    I have done pretty much the same thing from scratch twice so I assume that this is actually the correct behaviour for what i have built rather than a typo by me. I suspect there is something I'm leaving out because I have no clue what I'm doing.
     
  6. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #6
    OK, I have no idea about Storyboard. I do everything in code including the UI layout! You'll have to wait till someone who has used it comes along.
     
  7. Waragainstsleep thread starter macrumors regular

    Joined:
    Oct 15, 2003
    Location:
    UK
  8. CheesePuff macrumors 6502

    Joined:
    Sep 3, 2008
    Location:
    Southwest Florida, USA
    #8
    No offense, but if you have no idea what you're doing with programming then you should step back and take a while to familiarize yourself with the technologies, basics of the language, and how to build a view based app before going any further. If you don't you'll end up making a terrible application that may work but is coded extremely poorly, which in my opinion isn't worth it.
     
  9. Waragainstsleep thread starter macrumors regular

    Joined:
    Oct 15, 2003
    Location:
    UK
    #9
    Thanks for the opinion but I'm trying to do exactly that. I have not written any code at all which is why I'm thinking there is probably an easy fix for this.

    I'd love to try and learn the basics properly but I have yet to find any material that involves learning programming from scratch with Xcode. Every single person/book says the same thing: "Its really easy to learn to write iOS/Mac apps." followed by them whispering "By the way I already knew C, C+, C++, Java, etc, etc when I started learning Xcode".

    The 'app' I'm trying to build is nothing more complicated than a series of views. All (I thought) I did was put off-the-shelf transitions between them. I don't think it should need any coding, It just seems to go wrong when I have more than two views in play.
     
  10. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #10
    I know exactly what you mean. There is a bit of a problem that you have to learn both the Xcode programming environment and the C programming language at the same time.

    I really need to save the learning process as a text file somewhere so I don't have to type this out everytime, anyways, here's the process I used:

    1.) Get the book The C Programming language. Maybe even just rent it from your library for a few weeks. It a few decades old, it has a plain white cover with a plain big blue C on it. Learn the first few chapters. Do the exercises in it using Xcode.

    A little something I don't normally talk about while doing this whole spiel on how to learn iOS programming... To do the exercises from the book in Xcode, you'll want the Mac OS > Command Line template. At some point while setting it up, it'll have a drop down of languages to pick from, you want C. Your code belongs in the file main.m (I think, I'm not at my computer right now.)

    You don't need to learn everything from the C book, only the first third or so of the book is needed. Only takes an hour a day for a few weeks to learn all you need from C before moving on to...

    2.) Open iTunes, go into the store, and into the iTunes U section. Stanford has about 20 hours worth of excellent, free, iOS programming lectures that will take you all the way from knowing only C to knowing... Probably enough to make most any iOS app you'd like to make... And if you don't know enough, the lectures will also teach you where you can go to learn more advanced topics.
     
  11. mfram macrumors 65816

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #11
    Can't you just do this with a web page? You can build iOS-looking web pages with the appropriate CSS code. You don't really need an app for this.
     
  12. Waragainstsleep, Nov 24, 2011
    Last edited: Nov 24, 2011

    Waragainstsleep thread starter macrumors regular

    Joined:
    Oct 15, 2003
    Location:
    UK
    #12
    This is what I did to start with but I wanted to get rid of the menu bars at the top of the pages, and I didn't know how to automatically format it for iPhone, retina display and iPad accordingly.

    I was also hoping to maybe add some extra functionality later on. Ideally some kind of notification system. Thought it might be a good project to learn as I went.

    ----------

    Thanks for this. Is this the right book:

    http://www.amazon.co.uk/C-Programmi...3628/ref=sr_1_1?ie=UTF8&qid=1322182922&sr=8-1
     
  13. ArtOfWarfare, Nov 24, 2011
    Last edited: Nov 24, 2011

    ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #13
    That's the one. I thought it was older than just 1988 (I thought it was early, not late 80's,) but that's still it. I learned how to program from that book when I was in seventh grade and struggling with Algebra (I'd say the book actually taught me what a function was better than any Algebra teacher ever did...)

    Some people review it as being too... much? I don't know. They show you how to do some stuff and then ask you to take what you learn to do a few exercises. The solutions aren't in the book, and I feel like that's deliberate. It's teaching you to think, not copy down what someone else wrote. Plus when it comes to programming, there are generally many dozen if not hundreds of ways to get the same thing done and there's no need to have them say "Hey! You noob, your answer might "work" but it's not the same as ours! Change it!"
     
  14. Waragainstsleep thread starter macrumors regular

    Joined:
    Oct 15, 2003
    Location:
    UK
    #14
    Thats an updated edition, I think the original was 1978.
     
  15. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #15
    It's the same edition I own, but I suppose that could explain why I thought it was older.
     
  16. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #16
    That's not at all the case. It is quite possible to learn the C programming language (or even Objective-C) without touching Xcode. Command-line is your friend then.
     
  17. Waragainstsleep thread starter macrumors regular

    Joined:
    Oct 15, 2003
    Location:
    UK
    #17
    Do you know of any good guides that start at the basics with 'Hello World' and go on from there?
    Looking for one which is Mac-based since when I have tried in the past I run into configuration issues or problems trying to understand compilers and I struggle to ask the right questions because I don't know enough and most of the answers are for/from people using Windows and other IDEs.
     
  18. animefx, Nov 30, 2011
    Last edited: Nov 30, 2011

    animefx macrumors regular

    Joined:
    May 10, 2005
    Location:
    Illinois
    #18
    You will want to use XCode, it's the best IDE on the planet. There is no way to just jump into iOS programming without knowing C, and you will want to learn a lot of C before you move onto Obj-C since it is built on it. I would highly recommend you buy The Big Nerd Ranch Book on Obj-C, which will teach you the necessary amount of C before moving on to Obj-C about a 1/4the of the way through the book...

    I'm working my way through the book as well as watching Lynda.com's video series on Obj-C programming which is equally as impressive as The Big Nerd Ranch Book. If there is something I don't quite grasp in the book I'll watch the videos from Lynda.com which often help. I've currently stopped reading just before the working with Obj-C and objects chapter to make sure I've become fluent with C up until then. Accessing scructs members via pointers "->" instead of "*" is throwing me for a loop currently. I'm just not understanding it, but you'll run into syntax that just doesn't make sense to you... I advise going over things multiple times, and taking notes, because writing it down will help you memorize it!

    Best of luck
     

Share This Page