UIImage and UILabel outside UITableView - objective-c

Look at this image:
alt text http://img139.imageshack.us/img139/4488/picture2ep3.png
I know how to add UITableView with grouped style and how to add label in any table cell.
But how can I add image and labels on top on the view, like screen.

Using Interface Builder, you can just drag these (UILabels and UIImageViews) onto your view. If you're using a UITableViewController, you might want to switch to a standard UIViewController, to give you more control over what goes into the view.
After you've dragged them on, hook them up via outlets (if you want to programatically change/access them) or set their contents in IB and be done with it.

Related

How to add a button to static UITableView using storyboard

I tried to add UIButton in UITableView below UITableViewCells using storyboard.
However, the button width filled the whole area. I could net reduce the width of UIButton using storyboard. Do I have to add it programmatically?
I'm trying to active a result similar like the button in Viber setup, as shown below.
By adding the UIButton directly at the end of your table view, you're making it the table view footer, and the table view footer is required to take the whole table view width.
Try replacing your UIButton with a UIView, and add the UIButton in this UIView:

UIScrollView with controls repeating on every page?

I have perfectly working UIPageControl. I would like to add paging by swipe, and as I understood, it is done by UIScrollView.
But all tutorials are done with images, I want to have controls (labels, buttons) repeating on every page.
Because UIScrollControl is working the way that it must have set its width * pages count, does it mean, that controls can be placed only in code, not in IB?
Should I place labels and buttons directly on UIScrollView?
Thanks
If you have a View Controller designed using IB with all its buttons and labels, then it is possible to add that View Controller as a subview of your UIScrollView as such:
[scrollView addSubview:controller.view];
scrollView being your UIScrollView and controller being your IB designed View Controller.
You can achieve repeating controls with pagecontroll by using IB by ordering the objects appropriately. Here's what I have:
Drag the UIScrollview to the ViewController and also the drag the Page Controller and other controls also to the ViewController but not onto the UIScrollView. Keep them separate. The objects on the bottom of the IB list of objects shows up at the top of the view stack. (So when you swipe new pages the controls dont move and isn't covered by the UIScrollView) I also group the various controls by group selecting them and then use the "embed with view" menu item so that in IB I have two groups, the controls and the UIScrollView. Makes it neater and easier to manage. As for changing labels, I haven't tried it but I've seen tutorials where you can have iboutlets linked to changing value of pagecontroller and then update the labels in uiscrollview appropriately.

Custom Table in UIViewController Objective-C

I want to create table view inside of UIViewController like a below picture (I mean the second screen)
what is the best solution? "creating UIViewController then tableView and inside of tableView having custom cell"?
would you please give me some hint?
Thanks in advance!
So basically you want the tableview to not fill up the entire space. Yes, you can surely do UIViewController, let it implement UITableViewDelegate and UITableViewDataSource protocols, throw in a tableview and hook up the protocols, and use custom cells.
If you only want the tableview to not fill up the space horizontally (but it can still scroll all the way until it reaches your navbar), then you can just create a UITableViewController, and set up your cell background in the way you want. More specifically, you create 640px (or 320px) wide background images still, but only the central 600px, say, is filled in. The 20px to the right and left are transparent. (You need png to do this, of course) If you apply this background to your cells and apply another background to your self.view, then you can actually see your view background under the 20px on the two sides.
Note that if you choose the second approach, the cells are still full width; it's just that you are visually making them look like narrower. That's perfectly ok, but you need to customize your highlight background, too.
Looking at your picture, it seems you need to create UINavigation Controller as your parent view controller and add UITabBarViewController as its rootview. then in your second tab when your click on the cell inside the table, you pushview to another view which displays your picture
create a tab bar controller project. Every tabbar item will be a navigation controller.
Tat way u can manage both the navigation and tabs.

In Interface Builder, how can I add UIViews to a subview that is a part of a custom view I've created?

I am working to create a custom view for an iPhone app I'm creating. This custom view is a Popover dialog which is made up of a UIView which contains two images, a button to close the dialog, a label, and a UIScrollView. This view is named MDPopoverCard. I have these files as a part of my view:
MDPopoverCard.xib - The view as drawn up in Interface Builder.
MDPopoverCard.h - Defines a few IBActions and some other properties
MDPopoverCard.m - Implements some functions defined in the header
This is what it looks like in Interface Builder: http://cl.ly/2B0f2x3s1w1i0K2G0Q1r (sorry, I can't post an image yet as I'm new to stackoverflow)
There are a few properties defined in my .m and .h files that control whether the green button is displayed and what the text of the title label is.
I need to display a number of these dialogs in my app and I'd like to reuse this interface I've designed. I want to be able to add buttons and other form elements into the UIScrollView via Interface Builder. However, I have a problem:
Imagine that I have another view I'm drawing up in Interface Builder. I add a UIView to it and set its class to MDPopoverCard. I then drag a couple UIButton objects into my MDPopoverCard view. Here's an example of what it looks like in Interface Builder:
http://cl.ly/1X090h1t1q3f0i3E0917
This screenshot shows another view (the root view) that I've added my MDPopoverCard to. I've then added two buttons as subviews of MDPopoverCard.
These buttons do get properly nested in Interface Builder. However, when I run my app these buttons are added before any of the items that make up my MDPopoverCard view in the xib file. This means that the buttons are being added behind my popover dialog. That's the first problem.
The second problem is that I want these buttons and form elements to actually be added into the UIScrollView that's contained within the MDPopoverCard view, and not just right into the UIView's subviews array. Is there a way to specify this in Interface Builder? I'd really much rather draw buttons into my UIView and connect them to IBActions via Interface Builder than hand write every instance of these dialogs that I may need to display (several).
Any advice? Is there anything I can do to clarify the question?
Thanks for your help!
Formerly Xcode supported user-defined IB plugins for custom UI elements which you could just drag and drop into the XIBs the same way you do with built-in widgets. As of Xcode 4 this nice feature has been removed. (Thanks a lot, Apple.)
Currently I can only think of a hacky way to achieve what you described. What I would do is the following:
create an IBOutletCollection on your MDPopoverCard, e.g. embeddedControls
link it with every UI element (here: the buttons) you want to go inside the scroll view
implement the awakeFromNib in MDPopoverCard and explicitly reset the superview of all the views in embeddedControls to the scroll view in there
Hope this helps (although I haven't tried).

UISplitViewController: how to get toolbar if details controller is UITableView?

I checked out Apple's example on how to exchange detail views in the UISplitViewController and it seems that they put the UIToolbar in every detail controller. Then, if the device is rotated, they hide the toolbar or show it and add a popover button which will show the root controller.
I'd like to adopt this pattern to show my root controller in a popover using a button in the toolbar, but unfortunately, my detail controllers are all UITableViewControllers and they do not allow adding other UI elements than a table view. So how do I deal with that? Is there an example around?
René
I think I figured out by myself: DON'T use a ´UITableViewController´ and a UITableView as root view in your NIB, as you cannot add a UIToolbar to the table view.
Instead: In the NIB, put a standard view and drag a UIToolbar and a UITableView on it.
Connect the standard view to the controller's "view" outlet.
Add another outlet and make it a UITableView. Connect the table view to it.
In the code: Let your controller inherit from UIViewController and not from UITableViewController.
Add a property to your controller to get the TableView to make it look compatible to UITableViewController.
public UITableView TableView
{
get { return this.viewTableView; }
}
Upon the viewDidRotate event you will have to adjust the table views width and height now (UITableViewController did that job for you before):
this.TableView.Frame = new RectangleF(0, 44, this.SuperView.Frame.Width, this.SuperView.Frame.Height);
The 44 pixels com from the parent view's toolbar.
I don't miss UITableViewController. I know there are some issues like automatic scrolling when editing, but in my case this is simply not needed.
René
Check out this example and the corresponding code. If I understand your question, this should show you how to do what you're looking to accomplish.
Also, just as an FYI to everyone, another MT user MonoTouched the MultipleDetailViews example that you linked to above.