1

I want to design a view in xib and load it.

(This will be used as a footer view of tableView, and I don't have a xib at the moment for the viewController which will have the tableView.)
Suppose I will use this view from multiple places.(this footerView can be attached to tableView1, tableView2, etc)

The xib contains a view and this view contains a UIButton

I'd like to connect UIButton's touchUpInside event to something(File's Owner?, I'm lost here)

What should I do to use this UIButton?

eugene
  • 39,839
  • 68
  • 255
  • 489

3 Answers3

1

You might not know this but every table has a header and a footer (apart from the section with it's header and footer) and you can drag a new UIView to the bottom or the top of your table view directly in Interface builder. So like this you don't really need a separate nib file.

One you have added the UIView you can your button and other controls. When done you simply CTRL Drag from the button to your UIViewController subclass to create the IBAction for the button.

Illustration:

|-------- Table header --------|
|------ Section 1 header ------|
|--- Cell 1 for Section 1 -----|
|--- Cell 2 for Section 1 -----|
|--- Cell 3 for Section 1 -----|
|------ Section 1 footer ------|
|------ Section 1 header ------|
|--- Cell 1 for Section 2 -----|
|--- Cell 2 for Section 2 -----|
|--- Cell 3 for Section 2 -----|
|------ Section 1 footer ------|
|-------- Table footer --------|
Besi
  • 22,579
  • 24
  • 131
  • 223
0

Use the link below for adding a UIButton. All you need to do is wire up a button with a file owner, then you need to define the action in the file owner and wire it with the UIButton.

http://www.servin.com/iphone/iPhone-Buttons.html

http://mobile.tutsplus.com/tutorials/iphone/iphone-sdk-interface-builder-basic-training/

Asciiom
  • 9,867
  • 7
  • 38
  • 57
  • thanks for the answer, I forgot to mention something. I'm not editing a view for a viewController. I've updated my question. – eugene Sep 09 '12 at 07:56
0

there is ambiguity in your question ...

you have many tableviews and you want to assign the same footer with the same functionality i suppose for each?!!

-if you have a viewController without a nib and decided later to attach a nib to it , you need to do one simple thing (there are another way ) , by "file owner" go to "identity inspector" then under custom class write the name of the view controller ..

then back to your code initialize this viewcontroller with nibName and add it as footer from the delegate Method

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

I did not try that before ,, but if its the case I would do it programmatically

it will help ,if you added some code ...

Eng.Moath
  • 43
  • 2