Wednesday, October 19, 2011

iOS 5 Storyboard and UITableViews Tutorial

In this tutorial we will:

1. Create a UITableView from scratch.
2. Learn about navigation controllers.
3. Pushing view controllers with storyboard.

Link to Download Entire Project: here

1. Create a new single view based application called "StoryboardTutorial".


2. Select the main storyboard file and then select Editor > Embed In > Navigation Controller.
Note: A navigation controller is a way to manage views. Typically you push or pop a view onto a navigation controller. You can think of this a stack.


3. Next drag and drop a UITableView from the right sidebar and place it onto the view controller.


4. Go into the ViewController.h file and add after it says UIViewController. This tells the compiler that your class will conform to the UITableViewDelegate/UITableViewDataSource protocols. A protocol is just a formal way of saying that you will implement all methods that are required so you have a functioning tableview. 




Note: The biggest benefit of declaring the ViewController.h object as such is that now Xcode will autogenerate code and most of your necessary methods you would like to implement in the tableview class. Also note, if the method is not auto-generating you're probably doing something wrong. That's the main way I know I'm doing something wrong, or the program crashes.



5. Go back to the main storyboard file and "Control + Drag" from the tableview to the view controller and select "data source" and "delegate". This is how you tell the tableview where it is going to get it's data from, and if an event (a touch event for example) happens, who should it notify.


6. Now click on a tableview cell and click on the right side bar and go to the fourth panel from the left. In the field Identifier type "Cell". This is label so that you can reuse tableview cells which saves memory.


7. In the ViewController.m file implement these protocol methods.
Note: Philosophically it would make sense that you would needs to implement these methods to have create an actually tableview. You need to know 1) how many rows should you have and 2) what should you label these rows and 3) what to do when a user clicks on it.

Debugging Tip: Manually label the cells at first to make sure you made your connections correctly. I once spent three hours of my life trying to figure out why my tableview was empty. Save yourself the misery.



After you implement those methods it should look like this. I changed the table to states because I wanted to later show how to alphabetize a list of states.


8. Go back to the main storyboard file and drag and drop a View Controller object, and in the right panel type "detail" and the Identifier. This will be the detail view controller to push another view onto the view controller.


9. Go to File > New File > UIViewController Subclass and then create a UIViewController subclass called "DetailViewController" and unselect use XIB for interface.



10. Go back to the main storyboard file and in the right panel change the class of your newest view controller to be the "DetailViewController" that you just created.


11. Now go back to the ViewController.h file and then add "#import DetailViewController.h" at the top of your file. Then edit the two methods like below.

Note: What's new in iOS 5 is the storyboard and transitioning from one view to the other. Instead of having lots of Xib files, you replace them with views all placed into one storyboard file. This makes life much easier for the developer. So seen below is how you create a view controller object in storyboard.
"[self.storyboard instantiateViewControllerWithIdentifier:@"detail"" tells the computer to create the view that I called "detail" in the storyboard file, and then the "[self.navigationController pushViewController:detail animated:YES]" then pushes the view onto the view stack, so the visible view is then the current view.

Note: The tableview height method is self-explanatory. For some reason I had a hard time finding that method when I first started so I thought I would include it here for people to play with.


If everything is working correctly you should see these two screens if you select onto a tableview cell.

Note: In keeping with the states them I added two label to the detail view to work with later on.




12. Now if you can add a background image to the tableview cell by editing the cellForRowAtIndexPath method. Here I have a 320x65 pixel image called "LightGrey.png" which I'll include in the project at the end of the tutorial. Adding a background image really adds vibrance to your tableview.





13. Create a datasource by editing your ViewController.h and ViewController.m files so they match the ones below.
















Then make these changes in the ViewController.m file:



Changes:
1) @synthesize states and datasource.
2) In the viewDidLoad method call the function setupArray;
3) Create the datasource in setupArray;
4) Change the text label so that it reads from the datasource.

14. Edit the DetailViewController.h file so it matches the one below.



Then @synthesize them at the top of the DetailViewController.m file.


Then edit the viewDidLoad method.


15. Go back to the main storyboard file and select the detail view controller and "Control + Drag" from the DetailViewController to each of the UILabels and connect them to the appropriate outlet. 








16. Then go back to the ViewController.m file and edit the didSelectRowAtIndexPathMethod so it matches the following. This is just passing data from one view to the other.

So now when you select the state, the detail view will show the state's name and the state capital.








275 comments :

«Oldest   ‹Older   201 – 275 of 275
The Qb Payroll said...

whatever kind of issues users are preoccupied with. They can get effective solutions to fix error trouble of QuickBooks by dialling us Phone Number For QuickBooks at 1-833-780-0086. For More Visit: https://g.page/quickbooks-support-california?gm

The Qb Payroll said...

Enjoy uninterrupted benefits of the software with QuickBooks Support Phone Number 1-833-780-0086. Don’t hesitate to call on QuickBooks support ever. As you can get round the clock assistance from our QuickBooks experts. For More Visit: https://g.page/qb-support-oregon?gm

Ashok said...

Thank you For Giving Useful Information.
Python
VMWARE

Jack sparrow said...


Well thats a nice article.The information You providied is good . Here is i want to share about hyperion oracle training and Angular JS Training videos . Expecting more articles from you .

Mr Rahman said...

Really Nice Post & Thanks for sharing.
Oflox Is The Best Website Design Company In Dehradun

Amily said...

Facing technical issues in QuickBooks? Don’t worry, we are here to help you in resolving the error code of the software. call QuickBooks Customer Service Phone Number 1-855-9O7-O4O6 for reliable assistance.

Kaviya said...

Very interesting article with great useful information. Java training in chennai I am also sharing this article with my friends you have written excellent content. Thanks for sharing this kind of informative blog about Angular Js.
Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery

kevin32 said...

As a QuickBooks clientwhen your reaction to these two inquiries is a Yes without uncertainties and butsyou would need to take the correct measure to evacuate the mistake code -6000 rapidly and effortlessly which means that your work is not hampered for a more drawn out term.
Visit: https://www.dialsupportnumber.com/quickbooks-6000-series-error/

akshaya said...

This tutorial is irresistibly comprehensible and it is completely sensible. Thank you so much for this extraordinary article and this helps me to avoid mistakes. Web Designing Course Training in Chennai | Web Designing Course Training in annanagar | Web Designing Course Training in omr | Web Designing Course Training in porur | Web Designing Course Training in tambaram | Web Designing Course Training in velachery

thomas said...

Nice Blog!
Cancel QuickBooks subscription? Get live support 24*7 from QuickBooks expert on tool-free Number.
Click here to know how to Cancel quickbooks subscription
Dial for any tech support: 1-844-908-0801

The Qb Payroll said...

If getting issues in QuickBooks, get it resolved by calling QuickBooks Support Number 1-833-325-0220. Our highly skilled & dedicated experts are available 24/7 to assist you.

lavanya said...

It is very excellent blog and useful article thank you for sharing with us, keep posting.

Software Testing Training in Chennai | Software Testing Training in Anna Nagar | Software Testing Training in OMR | Software Testing Training in Porur | Software Testing Training in Tambaram | Software Testing Training in Velachery


The Qb Payroll said...

You are at the right place. Just call our experts at QuickBooks Technical Support Phone Number 1-833-325-0220 and get benefited with ideal resolutions to your queries. No matter how complex your issues would be, let our experts be informed about this.

thomas said...

Nice Blog!
Know More About QuickBooks error 6144 82? Get live support 24*7 from QuickBooks expert on tool-free Number.
Click here to know How to fix QuickBooks error 6144 82
Dial for any tech support: 1-844-908-0801

Anu said...

You have a good point here!I totally agree with what you have said!!Thanks for sharing your views...hope more people will read this article!!! DevOps Training in Chennai | DevOps Training in anna nagar | DevOps Training in omr | DevOps Training in porur | DevOps Training in tambaram | DevOps Training in velachery

thomas said...


Worried about How to install diagnostic tool ? if you are not able to install diagnostic tool, get in touch with QuickBooks expert for instant solution.
Click here to Know How to install diagnostic tool
Dial for fix QuickBooks error or support on QuickBooks toll-free Number 1-844-908-0801

Sharma said...

This blog is the general information for the feature. You got a good work for these blog.We have a developing our creative content of this mind.Thank you for this blog. This for very interesting and useful.

Digital Marketing Certification Training
AWS Certification Training
Python Certification Training
Selenium Training
Data Science Certification Training
DevOps Certification Training

thomas said...

Worried about Quickbooks error h202 ? if you are not able to fix Quickbooks error h202, get in touch with QuickBooks expert for instant solution.
Click here to Know how to fix Quickbooks error h202
Dial for fix QuickBooks error or support on QuickBooks toll-free Number 1-844-908-0801

thomas said...

Worried about QuickBooks error code 6129 0 ? if you are not able to fix QuickBooks error code 6129 0, get in touch with QuickBooks expert for instant solution.
Click here to Know how to fix QuickBooks error code 6129 0
Dial for fix QuickBooks error or support on QuickBooks toll-free Number 1-844-908-0801

sumathikits said...

Nice ...!
oracle identity manager training
hyperion training
Qliksense training
oracle scm training
mule esbtraining
django training
dot net training

Amily said...

Well explained and informative blog.
Amid uncertainty over coronavirus lockdown, we at QuickBooks Customer Service Phone Number 1-855-6OO-4O6O still provide 24/7 reliable assistance. All the queries related to QuickBooks will be answered by our QuickBooks experts.

Anu said...

very good post!!! Thanks for sharing with us.. DevOps Training in bangalore | DevOps Training in hyderabad | DevOps Training in coimbatore | DevOps Training in online

Fuel Digital Marketing said...

very nice blog.with great content sucessfull.Our team manages all your social accounts and organised regular engaging social media campaigns so that your business is always creating a buzz on social media.

digital marketing consultants in chennai | Leading digital marketing agencies in chennai | digital marketing agencies in chennai | Website designers in chennai

radhika said...

Greet post from blog. I always likes and such as super contents of these post. Kindly keep update like this.
AWS training in Chennai

AWS Online Training in Chennai

AWS training in Bangalore

AWS training in Hyderabad

AWS training in Coimbatore

AWS training

AWS online training

thomas said...

nice post!
Worried about QuickBooks error?Get in touch with QuickBooks expert for instant solution.
Dial QuickBooks Customer Service 1-844-908-0801

Anonymous said...

thanks for sharing with us.great article post.keep updating with us.River Group of Salon and spa, T.Nagar, provide a wide range of spa treatments, like body massage, scrub, wrap and beauty parlour services. We ensure unique care and quality service.

massage in T.Nagar | body massage T.Nagar | massage spa in T.Nagar | body massage center in T.Nagar | massage centre in chennai | body massage in chennai | massage spa in chennai | body massage centre in chennai | full body massage in T.Nagar

thomas said...

Lockdown is running in the whole country due to coronavirus, in such an environment we are committed to provide the best solutions for QuickBooks Support Phone Number.
Know how to fix QuickBooks error 1522 to get in touch.
Dial : 1-844-908-0801,1-844-999-0406.

thomas said...

Lockdown is running in the whole country due to coronavirus, in such an environment we are committed to provide the best solutions for QuickBooks Support Phone Number.
Dial QuickBooks Support Phone Number to get in touch.
Dial : 1-844-999-0406.

Kanika said...

Good Post! , it was so good to read and useful to improve my knowledge as an updated one, keep blogging. After seeing your article I want to say that also a well-written article with some very good information which is very useful for the readers....thanks for sharing it and do share more posts like this.
https://www.3ritechnologies.com/course/mern-stack-training-in-pune/

Unknown said...

Nice Blog !
Are you experiencing technical glitches & issues while working on QuickBooks? Don’t lose your patience!! By just contacting our QuickBooks Proadvisor Support Phone Number 1-888-597-O22O

Blogsilly said...

QuickBooks Error 15243 are associated with the QuickBooks FCS (File Copy Service) that is not working properly.

Blogsilly said...

To obtain back up in Registry Editor, select QuickBooks Error 15243 related error, select Export through the File menu.

kevin32 said...

QuickBooks Payroll Support Number
QuickBooks POS Support Number
QuickBooks Pro Support Number
QuickBooks Enterprise Support Number
QuickBooks Technical Support Number
QuickBooks Tech Support Number

Blogsilly said...

QuickBooks Support Phone Number
QuickBooks Tech Support Number
QuickBooks Technical Support Number
QuickBooks Pro Support Number

Blogsilly said...

QuickBooks Support Phone Number
QuickBooks Technical Support Number
QuickBooks Tech Support Number
QuickBooks Payroll Support Number

Anonymous said...

Give us a ring at QuickBooks Desktop support Phone Number 1-844-907-1907. Don’t ever let the technical issues impact your work process. Your one call can keep you refrained from every issue. Day or Night, our experts are available round the clock to offer help. Why waiting? Just connect with us to seek our aid.

Blogsilly said...

QuickBooks Enterprise Support Number

Blogsilly said...

QuickBooks Support Phone Number

Blogsilly said...

Pose a question to your query regarding this, dial our QuickBooks Enterprise Tech Support and get irked free of all hurdles.

Blogsilly said...


QuickBooks Support Phone Number
Support costing and different zone stock. Blunders THAT ARE SOLVED ON QuickBooks Premier Support Phone Number

Desktop enterprise customer have loads of mistakes. Dial Get quick help from QuickBooks Payroll Support Phone Number
r every minute of each and every day.
Therefore, it is mandatory to learn about certain basic steps, which could Enterprisevide QQuickBooks Enterprise Support Phone Number
t, as so when needed.

Blogsilly said...

It really is safe to state that you're trying to find a method to contact the QuickBooks ProAdvisors for specialized help? Dial the complementary QuickBooks Support Phone Number to get in touch because of the confirmed QuickBooks ProAdvisors and Experts. Would you like to become familiar with QuickBooks?

meritstep said...

I just loved your article on the beginners guide to starting a blog.If somebody take this blog article seriously
in their life, he/she can earn his living by doing blogging.Thank you for this article.
java online training

Blogsilly said...

QuickBooks Enterprise Support Number

aasik said...

huuuh amazing, really it is a useful article, thanks for sharing. Real estate dubai

meritstep said...

comment pega :I just loved your article on the beginners guide to starting a blog.If somebody take this blog article seriously in their life,
he/she can earn his living by doing blogging.thank you for thizs article. pega online training

kevin32 said...

Contact QuickBooks help Number If there’s any accounting software that is used by the world and popular for its features, it really is probably QuickBooks

kevin32 said...

However, if you want help, QuickBooks Support team is ready to serve you. Dial QuickBooks Support Number +1888-801-4256.

Blogsilly said...

You must at first review the latest version installed on your pc, and then upgrade your browser's version. For that please get in touch with the QuickBooks Support Phone Number
These are the few problems that users can experience when operating in QuickBooks Online, there may be more which are not right here now and users are asked to get hold of our autonomous Online QuickBooks SupportTeam by dialing our Online QuickBooks Support Number
o fix any errors when operating the QuickBooks.

Blogsilly said...

QuickBooks Support Phone Number

360digitmg said...

Great post! I am actually getting ready to across this information, is very helpful my friend. Also great blog here with all of the valuable information you have. Keep up the good work you are doing here.
Best Digital Marketing Institute in Hyderabad

Blogsilly said...

QuickBooks Enterprise Support Number

Arthur max said...

You have got some great posts on your blog. Keep up with the good work. If anyone is facing HP printer error 0x61000016 issue and want to fix the problem of fix hp printer error code 0x61000016? Just follow the steps which are mention on the blog to Resolve printer error 0x61000016 issue.

Anonymous said...

If bugs and technical glitches troubling you then one and foremost thing to do is to dial
QuickBooks Support Toll-free Number +1(844)233-3033 . A number that will lead you to the team of QuickBooks experts who are ready to help users like you at any time of the day with their best of knowledge and experience.
https://tinyurl.com/y3ohzofj
https://tinyurl.com/y24jdm5n
https://tinyurl.com/y35hmdp3

https://tinyurl.com/y3urbk6n
https://tinyurl.com/y6yg7seg
https://tinyurl.com/yyuu8a45

Unknown said...

https://www.digitalbrolly.com/seo-training-in-hyderabad/

saketh said...

Super site! I am Loving it!! Will return once more, Im taking your food additionally, Thanks. ExcelR Data Scientist Course In Pune

Anonymous said...

salome said...

informative article. thanks for sharing Angular training in Chennai

tech said...

This site was... how would I say it? Applicable!! At long last I have discovered something that encouraged me. Good wishes! best interiors

Apoorva said...

Nice blog.
power bi training

Apoorva said...

Thanks for sharing blog post.
devops online training

jasonbob said...

supreme clothing
yeezys
golden goose
yeezy shoes
moncler jackets
nike x off white
golden goose sale
jordan shoes
supreme
supreme clothing

Ravi Varma said...

At our institute we help you to Earn money online by practical real time examples.
Affiliate Marketing is a new career option. You can build a new career using this course
This training is best suited to people that look to Earn passive income
Single source of income is not sufficient, we will help you to generate multiple sources of money making
We give away a Free soft copy PDF of the affiliate marketing course material.
Unlike other institutes we will give you real-time awareness on money making techniques
Our trainers do Affiliate marketing. They will show you live money making tips with income proofs.
Missed a class, no problem free backups classes available upon mutual availability

Lokeswari said...

Gathered lots of information here, do share more updates.

web designing course in chennai | online internships for civil engineering students | online internship for mechanical engineering | online internship for mba students | online internship for computer science students | online internship for biotech students | internships for ece students | internship for electrical engineering student | internship for ece students

Choudhary said...

Wpc points of Nascent india wpc2027, Next we discuss about the pest control in meerut, Noida pest control in noida, Delhi pest control in delhi, Ghaziabad pest control in ghaziabad, Near Me pest control near me, now we see upon RO Service in Gurgaon

Choudhary said...

futurewithtech

Sruthi Karan said...

Excellent blog!!! I really enjoy to read your post and thanks for sharing!
Uncontested Divorce in VA
VA Uncontested Divorce

Oracle Fusion said...
This comment has been removed by the author.
Oracle Fusion said...
This comment has been removed by the author.
Ravikant said...

This is really a useful article. It will really help people learn about iOS. You can also check this UiPath training and CCSP training for a better understanding of it.


Well, thanks for sharing this article.

Techworld said...

Thanks for sharing this. You can also check this: learn r for data science

Techworld said...

Thanks for sharing this amazing article. azure development course

Techworld said...

Thanks for sharing this amazing article.automation anywhere course

Chaitanya said...

A big thank you for your blog article. Many thanks again. Awesome.
IBM Websphere MQ Training from Hyderabadg
ODI Training from Hyderabadg
Oracle Fusion PPM Training from Hyderabadg
<a href="https://viswaonlinetrainings.com/courses/oam-online-training/>Oracle Access Manager Training from Hyderabadg</a>

Prishav said...

Usually I never comment on blogs but your article is so convincing that I never stop myself to say something about it. You’re doing a great job. Keep it up mendix online training

Prishav said...

wow

«Oldest ‹Older   201 – 275 of 275   Newer› Newest»