Hello there fellow programmers,
I am wondering how to add the SDNestedTable into a project of mine.
Here is the source code for the SDNestedTable:
https://github.com/serverdensity/ios-SDNestedTable
I would like to add this table to a subview of one of my XIB's in my project.
Thanks, hopefully someone can help me out! :)
If you add a UITableView to your XIB file, then click on the second tab (right side panel) and in that make the class the SDNestedTable rather than your UITableView so it makes it that class instead, assuming also that SDNestedTable is a subclass of UITableViewController.
You should be able to then add your property to your .h file and attach it in your XIB:
#property(nonatomic, weak)IBOutlet SDNestedTable *nestedTable;
and in your .m file will go all the delegate methods you need that are also listed at the bottom of the github link you've provided, similarly to a UITableView and the dataSource and delegate methods they have I would imagine.
There are three problems (based upon the review of your actual source code that you posted in your other question):
You need to make sure you include the NIBs and PNG files in your "Copy Bundle Resources";
If you are going to support iOS 6, there is a bug in SDNestedTable and you have to change the cellIndexPath of SDGroupCell from assign to retain;
If you're adding the SDNestedTable (with its own controller) as a subview of SDNestedTableController as a subview, then you should use view controller containment.
All of this is explained in greater detail in my other answer to this question:
Works on iOS Simulator but not on iPhone
Related
I have a TabBar app with one of its tabs embedded in a NavigationController. This particular view is a form with text fields on it. I want to us the TPKeyboardAvoidingScrollView to move the UITextFields up when the keyboard moves into view. I have followed the instructions on the Github page but it just does not work at all.
This is what I have done as per the instructions:
Added the TPKeyboardAvoidingScrollView.h and .m to my project
Added a UIScrollView to the view on the storyboard (Xcode 4.3.1)
Selected the ScrollView and in the inspector changed its class to TPKeyboardAvoidingScrollView
Moved all my textfields into the UIScrollView
This did not work... So looking at the sample code I tried adding a few more things:
In my view controllers .h file I added:
#class TPKeyboardAvoidingScrollView;
and linked the ScrollView resulting in this line of code being added:
#property (weak, nonatomic) IBOutlet TPKeyboardAvoidingScrollView *scrollView;
Imported the TPKeyboardAvoidingScrollView.h into my controllers .m file.
But still the drop-in code that everybody else seems to praise just does not work for me.
Can anyone point out my incompetence please?
Thanks in advance for any assistance you may be able to provide...
I ran into this exact problem when trying to use this class as well and spent wasted a good deal of time on something that is supposed to be a time-saver.
I set breakpoints inside the TPKeyboardAvoidingScrollView and noticed that none of them were ever hit. After trying several things I noticed some output in the debug window:
“Unknown class TPKeyboardAvoidingScrollView in Interface Builder file” error at runtime
I found some helpful information in this thread. Basically it seemed that the file was being optimized out because it was never actually being used in the code anywhere.
In order to get it working again I did a couple things, any or all of which may be necessary:
Click on the TPKeyboardAvoidingScrollView classes in the project outline. Reveal the Utilities panel on the right side in Xcode if you have it hidden and confirm that the files actually have some target membership or they will not be built.
Delete the app from the device or simulator you are testing on so you get a fresh load.
Rebuild the project and load onto the device/simulator. The error should be gone, you should be able to hit breakpoints in the TPKeyboardAvoidingScrollView classes and it should all work now.
As an alternative you might want to look into the solution provided here by jhoule. The gist is that you add a call:
[TPKeyboardAvoidingScrollView class];
to your app delegate or elsewhere in your code to ensure that the code gets referenced and is not optimized out.
Hope that helps.
what you have to do is go to the main storyboard and add missing constraints of the scroll view or you can click on the scroll view on the storyboard and go to editor on top of the menu of xcode and go to resolve autolayout issues and click on reset to suggested constraints.run the project.Good luck.
I have some UIViewControllers from my old iOS4 project, they are using .xib, created in interface builder.
My new project, built for iOS5, uses storyboards.
I'm trying to add a UIViewController to the storyboard, but have it use a custom XIB that I already have. I've set the controller's identity in the indentity inspector (in interface builder), but am not sure how to ask that controller to load a custom .xib.
Any help is appreciated!
PS. Up to date I was able to get around this by creating a "wrapper" class for the storyboard purposes, and have that class have another UIViewController. But this kinda defeats the whole point of a storyboard.
You could copy the contents of the xib into the storyboard and then instantiate it using:
- (id)instantiateViewControllerWithIdentifier:(NSString *)identifier
after setting the identifier on it. If you need the instance of the storyboard you can get it this way:
[UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
Mike K's answer is false.
While mixing XIBs and Storyboards doesn't really solve Alex's problem, it is quite possible to do within the same project.
See: https://stackoverflow.com/a/8516479/1309238 re: loading a second storyboard.
I'm not sure if including a "Main Storyboard" in your Target Summary is advisable if you plan to do this, but if you've loaded a XIB instead of a storyboard to begin with, you can modify the code linked above to load the storyboard after the XIB.
I'm not sure if you can jump into the middle of a storyboard from a XIB, which may have been what Mike meant.
You cannot mix xibs and storyboards in your project -- it's one of the other, I'm afraid.
I am pulling my hair out on this one. I have a NavigationController with two levels of TableViews. Each TableView is in its own NIB file. The first level simply displays a list. Upon selecting a cell, it takes the user to a second level TableView with a more detailed list. It is on this second level TableView that I want to display a search bar (actually I am using a SearchDisplayController as well). I have added it to the TableView because I want the SearchBar to scroll with the table.
Below, I am displaying two screenshots. The first is the second level tableview in InterfaceBuidler. The second is the second level tableview at runtime. For some reason, the SearchBar doesn't display at runtime.
I have tried creating a completely new project from scratch and the same things happens. I don't understand why the SearchBar doesn't display on a NIB pushed on the NavigationController.
Before you ask, if I put the SearchBar on the first level TableView, it shows up just fine. Yes, I am adding it to the TableView itself, so it is a part of the view that should be displayed.
Help! What am I doing wrong?
This is what actually displays after the XIB is pushed...
Okay, I'm going to have to answer my own question. I thought about deleting it, but perhaps this could help someone else. I really pulled my hair out on this one. It wasn't because of anything I was doing wrong so much as a fundamental misunderstanding of how iPhone development works.
In a nutshell, the problem was with this line of code, which instantiated the TableViewController:
self.downloadDetailViewController = [[DownloadDetailTableViewController alloc] initWithStyle:UITableViewStyleGrouped];
When you use XCode to create a new class, you can use the following:
"Add -> New File -> Cocoa Touch Class -> UIViewController subclass -> UITableViewController
subclass AND With XIB for user interface"
The problem is that the NIB has absolutely nothing to do with the UITableViewController until you tell your code to use it. To me, this seems like a bug in XCode or at the very least something that is counterintuitive. When the development environment creates all three files together, it would only make sense that they would work together, but they don't.
Instead, the solution is to modify the line of code as follows:
self.downloadDetailViewController = [[DownloadDetailTableViewController alloc] initWithNibName:#"SecondaryView" bundle:[NSBundle mainBundle]];
Hopefully this can help someone else...
You could also set Nib Name property on your Download View Controller under the Tab Bar Controller, in fact that and coupled with setting the class with your class name will automatically create the view for you and you don't have to manually create it.
I think the problem is that you are adding the searchbar to the tableView, so it is not displaying.
Try to add that searchBar with out adding to the table view, that means move the table view some what down and add the search bar to the view(not the tableview).
I have been going through and re-creating Apple's "Advanced Table View Cells" example to better understand everything. I have done everything, but somehow missed one detail and I can't figure it out.
If you launch their example (http://developer.apple.com/iphone/library/samplecode/AdvancedTableViewCells/Introduction/Intro.html) and open up the RootViewController.xib file, they have a "tableView" outlet on the inspector that is linked to File's Owner. For whatever reason, I can't get that to show up on my version.
My code is almost verbatim of Apple's, so what am I missing? Did I not declare that somewhere or doesn't that get taken from the RootViewController.m file?
Did you set File's Owner to the class of the object you are trying to link to?
To check if you did so, open your xib file, and see if the File's Owner type is the class you want to link to.
If it doesn't and reads something else like NSObject, open the inspector, go to the Identity tab (Cmd+4), click File's Owner and in the Class Identity section, there's a dropdown menu with the list of classes in your project. Select your UITableViewController subclass and then try to make the link.
Their RootViewController subclasses UITableViewController. It is this that generates the tableView outlet.
So after being bugged by this problem for a while... I figured out a workaround. Please note that all of my code was exactly the same as Apple's and yet IB would never show a tableView outlet (as if it wasn't subclassing UITableView properly in my UINavigation Controller).
Essentially all I did was change the subclass from a UITableViewController to a UIViewController and then called the delegate and datasource protocols. After doing that and creating my own tableView outlet, I was finally able to hook up the tableView and get it working as it should.
#interface RootViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
used to be
#interface RootViewController : UITableViewController {
In Interface Builder, I dragged a UITableViewController object from the library into the project. Then, a tableview popped up. How do I get that tableview inside my already existing window?
Thanks, I'm totally lost!
That tableview is part of the UITableViewController, and is connected to its view property. The second window pops up so you can set that UITableView's properties directly.
If you're just starting out, I'd suggest checking out a few tutorial. The site I started learning from is called http://icodeblog.com/, and I'd also recommend the Beginning iPhone Development book by Jeff LaMarche and Dave Mark. Also, if you have iTunes, the Stanford iTunes class is a terrific way to learn in-depth about iPhone development, and it is free to download from iTunesU.
If you have created a view based application, the thing that you need is to add a uitableview from the library to the view. Be sure that you add uitableview, not its controller. It will be seen under dataviews
You have to take UIViewController first and bind it with view. Then add UITableView in your controller and bind it with IBOutlet object of UITableView.
Then you have to set datasource and delegate of UITableView. That's all. Now you can access all the methods of UITableVIew inside your controller.
If you still find any problem then please let me know. I will definitely help you out to solve this problem.