See this storyboard containing a Navigation View, Gestures, and a few Views.
Also within is a TabView, which contains an UIImageView and UITableViewController.
To apply my data to this TableView, I need to assign a Controller by using msExampleTableViewController.
The problem: the input/dropdown field removes entry after pressing Enter (like if this class is not assignable).
What is wrong here, and how can it best be done?
NA UITableViewController does assume that the root view will be a UITableView. When you combines UITableView with others controllers.. you can do in your Controller (ViewController in your case):
#interface YourViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
#property (nonatomic, assign) IBOutlet UITableView* tableView;
In Interface Builder set both the delegate and dataSource outlets of the table view to be equal to its superview's view controller (File's Owner)...
Now, Your view controller implementation should be the typical TableViewController implementation: cellForRowAtIndexPath, etc.
Related
In my application, I have a button that pushes a custom view controller (MenuViewController) on click.
#interface MenuViewController : UITableViewController
I wasn't able to resize the tableview. I tried:
self.tableView.frame=CGRectMake(0, 0,100, 100);
self.View.frame=CGRectMake(0, 0,100, 100);
in viewDidLoad and viewWillAppear. Neither of these methods worked.
I have an idea of creating a UIView initwithframe:.. and add MenuViewController as a subview.
Is this the proper way to do it?
MenuViewController is basically a general control that will handle variable init inputs
and will display the cells according to the inputs, the problem is the frame of the table view.
I believe that if you inherit from UIViewController and expose the UITableView as a property and also on the Interface then you can resize it. When you are using UITableViewController then it will always display in full size mode.
UPDATE:
So instead of doing something like this:
#interface TasksViewController : UITableViewController
{
}
You can do something like this:
#interface TasksViewController : UIViewController<UITableViewDelegate>
{
}
#property (nonatomic,weak) IBOutlet UITableView *tableView;
Also make sure that in interface builder you have a UITableView which is hooked to the tableView property in the TasksViewController. Now in your implementation file implement the cellForRowAtIndexPath method and return the cell.
I'm having issues assigning a custom class in storyboard.
In past projects I have overridden/subclassed UIPageControl to a custom class (ZZPageControl) by adding the .h to the view with the UIPageControl.
#import "MyPageControl.h"
#interface ScrollerVC : UIViewController <UIScrollViewDelegate> {
UIScrollView *scrollView;
IBOutlet MyPageControl *pageControl;
NSMutableArray *viewControllers;
BOOL pageControlUsed;
}
Then in IB I assign my custom class instead of UIPageControl.
Except my new project uses Storyboard rather than separate XIBs. When selecting the UIPageControl in the view and checking its class in the Identity Inspector only UIPageControl is listed. If I type MyPageControl is doesn't stick.
I've tried adding #import "MyPageControl.h" in the app delegate, in the view that initiates the UINavigation control, in the .pch file. I can't get my custom class to show up in the Storyboard.
How can I override the UIPageControl in the StoryBoard view?
I am making an app using a Navigation Controller, which I've set up like this:
0-Navigation Controller -> 1-View Controller (Root View)
1-View Controller (Root View) -> 2-View Controller (with class SubViewController) #1
1-View Controller (Root View) -> 2-View Controller (with class SubViewController) #2
1-View Controller (Root View) -> 2-View Controller (with class SubViewController) #3
1-View Controller contains a Text Field, UILabel, and 3 Buttons:
button #1 goes to 2-ViewController #1, #2 to #2, #3 to #3, using segue's (push) for the connections between the buttons and viewcontrollers.
If this isnt clear, I'll explain: If you press button #1 in 1-ViewController, you go to SubViewController #1.
Now where I'm getting stuck:
I want to communicate with a label in the SubViewController, but I can't draw a blue line (CTRL drag) from that UILabel to anywhere... (except the ViewController, which then gives the option: view, which doesn't seem what I need, I think).
What I want to happen:
The user enters data in the textfield in 1-ViewController, which then is displayed in the UILabel in the chosen 2-SubViewController.
How can I do this?
EDIT:
It seems that my Assistant Editor was set to Manual instead of Automatic. After switching back, I was able of dragging lines.
You'll have to do it manually:
add an IBOutlet for the UILabel in the UIViewController that should handle the label:
#interface MyViewController : UIViewController
{
IBOutlet UILabel *artistLabel;
IBOutlet UILabel *titleLabel;
}
#property (nonatomic, readonly) IBOutlet UILabel *artistLabel;
#property (nonatomic, readonly) IBOutlet UILabel *titleLabel;
you'll now have the option in Interface Builder to drag from your label to the corresponding UIViewController.
Hello I have a view controller that loads from an xib i created. It has two toolbars and a table view in that.
I add this too the header file in the ViewController
#interface FilterViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
When I do
[self.tableView reloadData]
It does throws up an error and does not build.
Just making your UIViewController conform to UITableViewDataSource and UITableViewDelegate does not automatically give you a tableView reference.
You need to create a tableView IBOutlet and connect it in Interface Builder.
Also, why not just inherit UITableViewController instead of a UIViewController?
I am trying to use UITabController as may controller in my main window and add navigation controllers to some tab bar items.
For example, the first tab has a navigation controller with table view:
alt text http://www.freeimagehosting.net/uploads/f3ad987c86.png
The SettingsViewController is associated with its own NIB file, where a table view is defined. Within that xib file, I have a table view and set it to the outlet of SettingsViewController class property myTableView.
Here are my h files:
// header file for SettingViewController class
#interface SettingsViewController :
UIViewController <UITableViewDelegate, UITableViewDataSource> {
UITableView *myTableView;
// other codes vars
}
#property (nonatomic, retain) IBOutlet UITableView *myTableView;
// ...
#end
// header for main app delegate
#interface MainAppDelegate :
NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
UIWindow *window;
UITabBarController *tabBarController;
// ...
}
#property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
// ...
#end
In my SettingsViewController.xib file, through IB, I linked outlet myTableView to the xib's file owner, ie, SettingViewController class:
alt text http://www.freeimagehosting.net/uploads/e577d35137.png
The problem is that in the main xib file, for the SettingsViewController navigation, there is one outlet myTableView. I am not sure if I have to set this to somewhere?
The exception I get is "[UIViewController _loadViewFromNibNamed:bundle:] loaded the "SettingsViewController" nib but the view outlet was not set."
SettingsViewController already has a view property. Are you sure this one is hooked up in Interface Builder? (You probably want it to be hooked up to your UITableView.)