Reusing One UITableView for Directory Listing Application - swift

Hello fellow StackOverflowers, I am in a bit of a dilemma with trying to condense the code in my application, iEngineering, that is available for free on the AppStore. Please download it so you can follow along with the rest of this post.
Alright, so when creating the current version of iEngineering, I used a new UIViewController with a UITableView for every "new" screen for all of the listing (table view) screens. The one story board file I am using currently has ~100 view controllers, takes 10 minutes to load, and several minutes to load the simulator. Big, big rookie mistake.
I am currently in progress in developing a plan to condense all of the UITableViewControllers into a single reusuable UITableViewController if it's feasible. However, I am running into trouble in figuring out what topics I should research to learn out how to refresh/present an updated listing (table view) in the view controller if you segue/transition to a subdirectory screen of the app. For example, selecting "Chemical Engineering" in the home screen and transitioning to the next listing screen that displays the following: "General Chemistry, Fluid Mechanics, Reactor Design, Separations, and Thermodynamics."
Would this be a reasonable/feasible task to condense down my current project? If so, what topics should I research to figure out how to do the transitioning/updating to a new table view screen?
In the images below, I am trying to condense the view controllers into only a couple of view controllers (Note: The image doesnt display the 80+ view controllers off the screen. xCode wouldn't zoom out anymore.)

Related

Loading MKMapview in background to avoid delay issues

I'm building an iPhone app (in iOS 5) with several different views, one of which contains a map (also has separate view controller). The first time I go over to this view, it takes a while for it to load, and things such as animating pin drops also don't work well as a result of it. Not to mention that it takes a bit for the location to stabilize.
What I want to know is if there's a way to load MKMapView before a user goes to that view, so by the time they get there, these issues aren't present anymore.
I've already seen this and this question but they haven't been very helpful. Keep in mind that I don't really need to interact with that view before I get there, I just want it to be fully loaded by the time I go there.

ios app second screen

I am a beginner to the iOS app development and working on a sample app that consists of just two "screens" - the first screen authenticates the user against user id and password saved in a SQLite database table and the second screen displays list of users in the database if user authentication is successful. If authentication fails I would just like an alert displaying appropriate message to the user.
I somehow can not connect how to "go to the second screen" if user authentication is successful. How can I tell the application that now that the user is authenticated it is time to go to the second screen and display the list of users?
I apologize if the terminology I use is not standard iOS app development terminology but I am new and would like to fill the gaps in my understanding. Please feel free to direct me to any links/tutorials/documentation.
Thank you.
Navigation is a fundamental and essential part of iOS programming and UX design. Traditionally, views are managed by ViewControllers, which in turn may be managed by NavigationControllers in stacks. To naivgate between and away from controllers, we define two new verbs: Push and Pop. To go to a new view, one pushes it onto the navigation stack. To transition away from a view, one pops it off the stack. And so, with these two paradigms, we can define simple transitions which are managed by the UINavigationController object. Have a look at the navigation guide in the docs before you proceed any further.
You don't appear to have sufficient understanding of iOS basics for any of our answers to be helpful. A word of advice: don't waste your time wrestling with code before you have a bit more of a foundation; you will just become frustrated.
Take a few hours and review some of the videos in Paul Haggarty's Standford iOS course.
Once you understand some of the building blocks and concepts of the API, things will move along much more quickly.
Are you developing against iOS with Storyboards?
If you start with the boilerplate "Master/Detail" template in Xcode for iOS 5 with Storyboards, you will get some sample code for a master view (uses a UITableView), detail view (uses a UIView with a label in it), and a segue between the two view controllers to go from master to detail, along with a "Back" navigation button that pops the detail view off and back to the master view.
The iPad boilerplate for that type of project is slightly different in the it uses a UISplitViewController to show both master and detail at the same time and doesn't use a segue between the two.
You could take a look at that boilerplate code, modify it, and go from there.

Programmatically Code a UITableView for iPhone Application in Xcode 4.2

I have been working in Storyboards for a while now and they are perfect for smaller apps. But I'm trying to put together a collection of 40+ recipes so it's unrealistic for me to drag 40 different Detail Views onto the Storyboard!
I'm wondering how can I programmatically build a table view with 40 different rows that each lead to the same Detail View, but pull different content? Thinking of storing the content in an array and based on which table cell the user clicks we pull from a different index in the array. So for example if the user clicks on recipe #2 in the table it will load a generic Detail View which populates its data from my array index #2.. Please ask for clarification if I'm not making any sense.
I've looked through the Apple docs and a lot of their tutorials reference Core Data which I would like to not use... I don't think it's required for iOS 5 and there must be an easier way than using Storyboard to drag-and-drop 40 different Detail Scenes.
Your question is at a very high level so I can't provide much help other than to provide guidance. Your idea in the second paragraph sounds exactly how you should write your application in iOS.
You build a model containing your recipes (CoreData or other store)
Link this to a navigation controller hosting a table view controller (NSFetchedResults controller or your own code or a combination of both)
A selection in the table view pushes the (generic) detail view controller onto the Navigation stack (using the push segue is probably easiest)
The detail view controller populates itself (with the detailed recipe instructions) using a unique name that you pass to it that will enable it to load the detailed recipe from your data store
In fact, I believe that Apple demoed an example app that did exactly this during either WWDC
2010 or WWDC 2011.
If there's any section you are not clear on, post a new question detailing what the problem is, what you've tried so far and/or what your errors are.
Hope this helps.

Architecting iPhone Views - seeking help on a specific issue + general advice

I am primarily a web developer (ruby, python) that is new to iPhone development. I've done some desktop development in the past within the MS environment (C#), but never anything on the mac.
I'm trying to build a really simple iPhone application and I am confused by the way that views work in general. If someone can provide advice for my particular problem, along with some resources where I can learn how to architect iPhone views in the future, that would be awesome. I feel like a lot of the Apple documentation that I've come across is too specific - I am lacking a fundamental understanding of how views work on the iPhone.
My particular problem looks like this:
I need one view that displays some downloaded text content. This is the view that shows when the app loads, and it is pretty straightforward.
Then I need a settings area (I've already decided I don't want to use the iPhone settings area). The settings area main page will have some text fields on it. It will also have a 2-row grouped table. Each cell in that table will take you to another view which also has a grouped table used for multi-select. I suspect that I can reuse the same view for these two final "detailed setting" views.
In summary:
home page
settings main page
detailed setting 1
detailed setting 2
Any help and advice appreciated.
It sounds like you already have a good idea of what you want each of your screens to look like; that's a good place to start.
What you're probably going to want to do is use Interface Builder to lay out the objects in each view (textfields, buttons, etc.), and then have a custom View Controller (subclass of UIViewController) for each view. You would then navigate to a new view by doing something like:
MySettingsController *controller = [[MySettingsController alloc]
initWithNibName:#"SettingsView" bundle:nil];
[[self navigationController] pushViewController:controller animated:YES];
(assuming a navigation-based app).
If you haven't yet, I recommend reading Apple's View Controller Programming Guide
Some advice: Despite your back ground, don't think of the views as pages or the app as a web site. That will cause you problem in your design because the technology is different and views don't work like web pages and apps don't work like web sites.
The major difference is that while web pages often contain actual data, views do not. The view object is only concerned with display. It doesn't know what it is displaying and it doesn't store or logically manipulate the data. The data comes into the view from the view controller which itself gets it from the data model.
See Cocoa Core Competencies: Modal View Controller
Rails uses MVC if you've used that with Ruby. The basic principles are the same.
Well, there are plenty of information on Apple developers' pages: you could start reading Your first iPhone application
There are quite a few good sites with very good info both on cocoa and iPhone developing:
Cocoa with love
iCode blog
and many more (google is your friend in this).
A couple of books I liked are "Beginning iPhone3 Development" and "iPhone developer cookbook".
The first is probably more useful at the beginning (no pun intended)
As for the specific case of yuor application, you could use a navigation controller for the settings page, and each time you need to dive into the details you will just push the right view onto the navigation controller's view stack.
So you would design 4 views with the interface builder
Main view
Settings view
Detail 1
Detail 2
And then push the views onto the navigation controller.
It's pretty straightforward, I won't go into the details, but just searching something like "iphone navigation controller example" on google will give you plenty of samples that you can easily adapt to your needs.
These were all helpful responses, in particular the reference to the iPhone View Programming Guide. This helped me to diagnose my misunderstanding which was related to the role of View Controllers, and the relationship between individual views and view controllers. I think part of my confusion came from learning MVC in the context of Rails, where this relationship is quite different.
For others looking for advice in this general area, I would recommend checking out Lecture 6 from Stanford's iTunes U iPhone Application Development course from Winter 2010 "Designing iPhone Applications, Model-View-Controller, View Controllers", and the lectures 5 & 7 if you have time. I think that was when the penny dropped for me, despite having already looked at a few of the books mentioned here.

Best UI element for displaying results of XML parsing

i am a student and also new to iphone SDK.i want to do xml parsing which has image URL and Data,it is a XML file about news.i have to show it .can i use table view or navigation controller? which is the best way?i have to show images and titles in first page.when i click it,it shows other page to show full news with image. is there any tutorial for what i need?
Table View and Navigation controllers are two entirely different things. It's like asking whether you should use a hammer or a nail to hang something. You could use both. YOu could also use a screw and a screwdriver, or any number of other ways to hang something on the wall.
A Navigation controller allows you to move around in a view heirarchy. See the Apple Contacts app to see how you can move around. Now, if you want to have a list of items, then you could use TableView to make a table of items. You don't have to have a UITableView inside a Navigation controller view. Or you may want to.
I would start at Apple's Creating iPhone Apps, and then go look at the Stanford's online course, and this one, among countless others.
You have chosen to bite off quite a big chunk with your first project.