UITableView in UIViewController in Xcode5 not working - uitableview

I've done this successfully before in past apps under Xcode4 but it doesn't seem to work anymore in Xcode5. In short, I like to add a UITableView into a UIViewController. Part of the process requires that I add as properties into the cell.h any GUI elements that it contains such as UILabel. The problem is, I'm no longer able to ctrl-drag those elements into the cell.h.
Main.storyboard
UIViewController, UITableView, UITableViewCell
The UITableView has the UIViewController as datasource and delegate.
Please assume I'm using the correct delegate methods in the ViewController.m file.
testViewController.h
#import <UIKit/UIKit.h>
#import "testCell.h"
#interface testViewController : UIViewController
<UITableViewDataSource, UITableViewDelegate>
#property (weak, nonatomic) IBOutlet UITableView *myTableView;
#end
testViewController.m
#synthesize myTableView;
testCell.h
Issue: Unable to ctrl-drag a UILabel from the cell into this file as I've done on past apps.
testCell.m
Nothing added.

I got it to work by manually typing in the IBOutlet property and linking it that way.
ctrl-drag still does not work FYI.

Related

I can't connect an object class file to a uitableview? ios objective-c

Hi I am trying to integrate http://www.scott-sherwood.com/tutorial/ios-5-drag-and-drop-between-uitableviews/ tutorial's function that we can drag and drop objects between two UITableViews located in a UIViewController.
But In the tutorial it has 2 tableview class files(without xib / ui) that connects to 2 tableviews which located at SSViewcontroller as objects.
In the sample source code they provided, I can drag from object to UITableView to connect.
But when I try to do with my project I can't connect and tableview is not active.enter image description here
Any ideas to connect the tableview to the object that has a UITableView class.
You need to specify outlets in the UIViewController subclass that is your file owner. For example, in my case I have these two outlets:
#interface ViewController ()
#property (nonatomic, strong) IBOutlet UITableView *tableView1;
#property (nonatomic, strong) IBOutlet UITableView *tableView2;
#end
and in Interface Builder it looks like that:

Cannot create new outlets in interface builder, old ones have a warning symbol

I am not sure what is causing this problem, but I now cannot create outlets. When I create an outlet it appears and works fine in code, but does not appear under the view controller in storyboard. Old outlets have a warning symbol on them like this
When I remove this outlet, its gone and does not appear back to connect. I am running Xcode beta 6.2 because moving to 6.2 temporarily fixed this problem because I was having it beforehand in 6.1.
Here is the .h file of this class
#import <UIKit/UIKit.h>
#interface DashboardViewController : UITableViewController {
NSString *currentDay;
}
#property (nonatomic, weak) IBOutlet UILabel *dayLabel;
#property (nonatomic, weak) IBOutlet UILabel *blockLabel;
#property (nonatomic, weak) IBOutlet UILabel *currentClassLabel;
#end
and here are the outlets listed in storyboard
These are the details of the warning, but this is .h file's code for this class
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#interface InfoViewController : UIViewController {
IBOutlet UIScrollView *AISScrollView;
IBOutlet MKMapView *AISMapView;
}
-(IBAction)studentHandbook:(id)sender;
#end
Oddly enough, I ended up finding a solution and that was moving the project out of the directory that it was in. It was in my Dropbox folder and moving it out fixed. If anyone has this problem in the future and also happens to have the proj in their Dropbox, move it out.
try to change this:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#interface InfoViewController : UIViewController {
IBOutlet UIScrollView *AISScrollView;
IBOutlet MKMapView *AISMapView;
}
-(IBAction)studentHandbook:(id)sender;
#end
to that:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#interface InfoViewController : UIViewController {
}
#property (nonatomic,weak) IBOutlet UIScrollView *AISScrollView;
#property (nonatomic,weak) IBOutlet MKMapView *AISMapView;
-(IBAction)studentHandbook:(id)sender;
#end
Just in case someone suffers from the same thing again, the best answer inside this other thread did the trick for me:
XCode 6: can't connect any IBOutlet to ViewController
Removing the .h and .m files from the project (their references) and readding them again was the solution that worked for me.

UITableViewController loadView loaded nib but didn't get a UITableView.

When I run my iOS simulator, I get this error:
UITableViewController loadView loaded the I1u-ML-mqb-view-QFc-WC-CU4 nib but didn't get a UITableView.'
My code:
#interface IF2000 : UITableViewController
#property (weak, nonatomic) IBOutlet UILabel *EnterCategory;
#property (weak, nonatomic) IBOutlet UITextField *Tfield;
- (IBAction)Submit:(id)sender;
#property (weak, nonatomic) IBOutlet UITableViewCell *EmptyCell;
#end
This is the only code that I have typed so far. If anyone knows how to solve this problem, I would appreciate the help. If I could get a general answer on how to solve this problem, that would be good as well.
Your nib file contains a view other than a table view as the first object. When you try to load a UITableViewController with a nib, you must make sure to have a table view as the first object.

UITableView delegates not recognised after switching from UITableViewController to a UIViewController with separate UITableView

My problem is that until now I used a ViewController and inside this I create the UITableView programatically. For this ViewController I have created a class named WalkTroughViewController and set it inside Custom Class inside Identity Inspector.
Now I have changed, and I create another ViewController(deleted the old one) and drag a TableView from the Object Library. Then I have set the Custom Class of this new ViewController to WalkTroughViewController, but now when I run the project my UITableView delegates are not called.
I have also dragged a UITableViewCell inside the UITableView and set it to my custom cell class.
Any pointers what I have done wrong ?
edit:
#interface WalktroughScreenViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
- (IBAction)nextScreen;
#property (weak, nonatomic) IBOutlet UIButton *button;
#property (strong, nonatomic) IBOutlet UITableView *tableView;
#end
You can drag and assign the delegate and the dataSource of the table in the story board to the fileOwner (Your Controller)
or simply assign it programatically in ViewDidLoad method
self.tableView.delegate = self;
self.tableView.dataSource = self;
Did you assigned the delegate and the dataSource?
did you define
#interface YourClass: UIViewController <UITableViewDelegate, UITableViewDataSource>
Copy paste the code of your header so we can provide more help and see what's the issue

merge iAD within another view / definition

i am having trouble merging iAD into my current code/definition. i already have code set for a card scroll view style display and wanted to add iAD to the same view controller:
how can i do that without getting the errors i am getting?
this is the code for card scroll view in view controller.h
#interface ViewController1 : UIViewController <CardScrollViewDelegate>
#end
this is my code for iAD for view controller.h but should be merged with the above otherwise i get another error saying duplicate definition:
#interface ViewController1 : UIViewController <ADBannerViewDelegate> {
SLComposeViewController *mySLComposeSheet;
}
#property (weak, nonatomic) IBOutlet ADBannerView *banner1;
The view controller name / custom class im trying to add them both to is ViewController1
UPDATE:
its much simpler than i thought, just add a comma (FOR THOSE WHO ARE CURIOUS LIKE I WAS)
#interface ViewController1 : UIViewController <CardScrollViewDelegate, ADBannerViewDelegate> {
}
#property (weak, nonatomic) IBOutlet ADBannerView *banner1;
#end
Your code and/or question is ambiguious. I see 3 view controllers and 2 delegates. Eitherway...which viewcontroller are you trying to add it to? Whichever one it is. Inside the implementation file should be the following:
Remember to import iAd and your code should look like this:
#import <iAd/iAd.h>;
#interface ViewController1 : UIViewController <ADBannerViewDelegate>
{
ADBannerView *banner1;
BOOL bannerIsVisible;
}
#property (nonatomic,assign) BOOL bannerIsVisible;
Then, in viewDidLoad you can load it in a frame etc...

Resources