UIImageView - class never called - objective-c

I'm using StoryBoard to create my app.
I created a custom class of UIImageView. In StoryBoard I added a UIImageView in my view and linked it to my custom class.
My class is never called and my imageview is not displayed. Did i miss something? Thanks.

Related

Navigation Controller .. Table view Background image

When I add a Navigation Controller, I have two views: A Navigation Controller and a Table View.
I want to add static cell in the Table view. The Table view class is UITableViewController. How can I add a background image to the Table View Controller?
I have no Class where I can write in the code. I am a Beginner in Xcode. Where can I add the code:
UIImageView *bg = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"MyImage.png"]];
[tableView setBackgroundView:bg];
http://i.stack.imgur.com/zgJYk.png
or where there is an example?
thanks for your help
I don't think you can add a background image to a UITableViewControll from storyboard. What you have to do is create a custom class for your UITableViewControll and add the code in the ViewDidLoad method to add your background.
Create A Custom Class
dropbox.com/s/zqh5zu02f2dt0zo/create_custom_class.png
Assign your custom class to your Storyboard tableviewcontroller.
dropbox.com/s/5l94b9htfa1mz2w/add_custom_class.png
Add your code in the ViewDidLoad for your background image.
dropbox.com/s/2kz6m4iku27kyxz/code.png
Your app should now have a custom background behind the tableview.
dropbox.com/s/ks4riraqblaluoy/app.png
I hope that helps.

Static UITableView not fullscreen

For my registration form, I am currently using a UITableView which isn't fullscreen and I add cells programmatically through hardcoding the datasource methods. By the time the whole class got very complex and huge.
Pastebin link
The cells are custom and have a UILabel and a UITextfield. Now one of the cells should have a button instead of the textfield. This would make the whole thing more complex then it should be, in my opinion. So my thought was using the static feature of the tableview in the storyboard. But this requiers a UITableViewController, if I use one the TableView is always fullscreen. Is there a way to se the static feature without a fullscreen TableView??
If you have a fixed number of cells, the static table view controller is a good option. Instead of implementing the datasource methods, as you mentioned, you can include each input field as an IB outlet.
If you want a static table view controller that is not full-width, embed the table view controller inside a container view.
For example, create a new view controller, add a container view object w/ the desired width in this new view controller, and then connect your static table view controller to the container view.
Note that the static table view controller becomes a childViewController of the enclosing view controller. You can facilitate access to the textFields from the enclosing view controller w/ a weak property to the textFields w/in the child view controller.
- (UITextField *)surnameTextField
{
UITextField *textField;
// reference childController that is initiated via containerView
if ([[self.childViewControllers lastObject] isKindOfClass:[NameViewController class]])
{
NameViewController *nameVC = [self.childViewControllers lastObject];
textField = nameVC.surnameTextField;
}
return textField;
}
You do not need to use a UITableViewController. Just drag and drop a table view from the control palette onto a UIViewController in your storyboard. Size and position it how you want to and add any other controls to the UIViewController that you need.
In the property sheet for the UITableView set the content type to 'Static Cells' then define your cells how you want them.

How to connect to a nib from within StoryBoard?

I have some code (ILColorPicker) that I want to install into my iPad app, which is using StoryBoards. The instructions from the author say:
In your view controller's XIB, add a UIView and then set it's class to ILColorPickerView
Wire the delegate property of the ILColorPickerView to your view controller in Interface Builder by selecting the UIView and clicking on the last tab. Then click on the circle next to "delegate" and drag that to "File's Owner" on the left.
Implement the delegate method: colorPicked:(UIColor *)color forPicker:(ILColorPickerView *)picker
How do I do this, when I am using Storyboards and there is no delegate or "File's Owner"? I have created a class with a subview to hold the picker, but see now that I don't need the subview. With that in mind, how do I connect this to my controller's view?
Files Owner is the View Controller. You don't need a Nib file for this, you can use a scene with a ViewController and just follow the directions from there. You can add a class (of type UIViewController) to you app and then associate that class with the VC in storyboard. That class will be the "Files Owner".

Add UIView on UIViewController

I want to add a "custom" uiview onto a uiviewcontroller, this custom view i created with xib and its a seperate from the view controller,
does anyone know how to add a uiview with a xib into a uiviewcontroller?
Many thanks in advance
You mean an additional view, not the main controller view? In that case you can declare a property for the view and load the NIB by hand:
#interface Controller {}
#property(retain) IBOutlet UIView *extraView;
#end
…
- (void) viewDidLoad // or anywhere else
{
[[NSBundle mainBundle] loadNibNamed:#"extras" owner:self options:nil];
NSAssert(extraView != nil, #"The extra view failed to load.");
[[self view] addSubview:extraView];
}
This assumes that you set the Controller as the file owner in the Interface Builder and you link the view to the extraView outlet. Also note that there might be more elegant solutions, like inserting the extra view into the main NIB for your controller; depends on the situation.
It looks like you want the most common scenario – simply load an intialized custom UIView subclass into a controller.
Create a new XIB, called “View XIB” in the Xcode new file wizard.
In the Interface Builder select the File Owner object and on the Object Identity tab in the Object Inspector (Cmd-4) enter Controller (or however your controller class is named) into the Class field.
Do the same with the view, entering the name of your view class.
Ctrl+drag from the file owner to the view, you should be able to connect the view to the view outlet defined on your controller.
Save, let’s say Controller.xib.
In your code, initialize the controller using initWithNibName:#"Controller" bundle:nil. The initialization code should load the interface for you and set the view property to the view unpacked from the interface file.
Go through some Interface Builder tutorial, IB is a very nice tool and it’s good to be familiar with it.

Loading Accessory callout view for mkannotationview

I have a map annotation view that contains a rightcallout button which loads an accessory view which is a UIViewController class. I am using resuable annotations, but am wondering how I can pass updated information to my UIViewController class. Let's say I have 2 string values which map to 2 UILabels on my view. How can I update those values after the initial accessory view has already been loaded into memory as a resusable view?
Any help would be appreciated.
You'll need to maintain a reference to the UILabels in the object that gets the update, and then use setTitle: (I think) to update the labels.
In your annotation subclass you need to override the setTitle method to send the changes to the instance of your UIViewController class that your subclass is holding. Or, you could setup your annotation subclass to receive notifications (from NSNotificationCenter), and upon receiving a notification, update the title and the instance of your UIViewController class.
If you are unfamiliar with NSNotifications, then here is a quick reference. I used these to keep my annotations updated.
NSNotification Example
Try using the MKMapViewDelegate method:
-(void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control;
This method is called when a user tapped one of the annotation view’s accessory buttons. Assuming that your MKMapViewDelegate is also the UIViewController that can access your accessory view.