So, I'm trying to do a list with images, with different height, like this:
_______ _______
| IMG1 | | IMG4 |
|_______| | |
_______ | |
| IMG2 | | |
| | |_______|
|_______| _______
_______ | IMG5 |
| IMG3 | | |
| | |_______|
| | _______
| | | IMG6 |
|_______| |_______|
And the people can scroll. I thought about using TableView, but the UITableViewCell must have a fixed height. Any idea?
If you have fixed 6 image of fix size,then i suggest to use six uiimageview of whatever size you want place in scroll view, and then set image programmatically.
UITableView supports cells of varying heights, via the tableView:heightForRowAtIndexPath: method of its delegate. But if you want two columns of images, where all the images are different heights, you'll need to use UIScrollView.
Related
If I use a standard UIViewController or UITableViewController, navigation bars and tool bars appear translucent on top of the content. However, if I use my own custom view hierarchy, I no longer see the effect. In the following screenshot, you can see that the table view does not appear underneath the sticky toolbar.
The UIToolbar's is initialized like so:
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.translucent = YES;
self.barTintColor = [UIColor colorWithRed:1.0f green:0.0 blue:0.0 alpha:0.1f];
// irrelevant code here
}
return self;
}
The actual loadView of the UIViewController is quite long, so I'll just show a diagram of the layout:
___________________________
| _______________________ | <-- UIView (self.view)
| | | |
| | UITableView | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| |_______________________| |
| _______________________ |
| | UIToolbar | |
| |_______________________| |
|___________________________|
I made sure to set the edges for the extended layout in viewDidLoad:
self.edgesForExtendedLayout = UIRectEdgeAll;
The documentation for edgesForExtendedLayout is a one liner, so I'm stuck on what other interrelated things need to be put into place to get the tool bar to be translucent.
Your tableView should extend and fill the entire view. Then you can set a contentInset which is the height of the navigation bar on the top as well as the toolbar on the bottom. That way you can see the content flow right through. Heres a snippet of code on how to do that. Make sure that the tableView is right at the bottom of the view hierarchy and that the navigation bar and toolbar are on top of it.
self.tableView.contentInset = UIEdgeInsetsMake(NavBarHeight, 0, ToolBarHeight+distance_Of_ToolBar_FromThe_Bottom_of_view, 0);
In the view hierarchy, seen in the diagram below, I would like to be able to drag the portion of the map that can be seen through the clear UITableView (2).
--------------------------------
|1. MKMapView |
| -------------------------------
| |2. Clear UITableView | |
| | Content Offset | |
| | | |
| | | |
| -------------------------------
| |Cell |
| -------------------------------
| |Cell |
-------------------------------
The MKMapView is behind a UITableView. The UITableView that has a positive content offset and a clear background.
At the moment the UITableView is taking the gesture and the map can not be panned. How can I tell the table view that is should only scroll when the cells are panned.
If you can, change the frame of the table view so it just isn't placed over the map.
If you can't, subclass the table view and implement hitTest: to decide if the user interaction should be handled by the table view or not.
I'm writing an app that has a view with nested UITableViews. The UITableViews in the cells of the outer UITableView are rotated 90 degrees so that they scroll horizontally. The UITableViewCells in the main UITableView are of the class HorizontalTableViewCell.
UITableView
--------------------------------------------------
| | | |
| | | | HorizontalTableView
| > | > | > | (contained inside
| | | | UITableView's
| | | | UITableViewCell)
--------------------------------------------------
| | | |
| | | |
| > | > | > | |
| | | | \ /
| | | | "
--------------------------------------------------
| | | |
| | | |
| > | > | > |
| | | |
| | | |
--------------------------------------------------
When in portrait mode, I have the content spaced evenly by setting the HorizontalTableView's width to the screen width in the initWithFrame: method.
I would like to increase the cell padding of the HorizontalTableView's cells such that when the device is rotated to landscape mode, the 3 cells are resized to fit the entire screen, each taking up an equal amount of space.
However, the best I can seem to achieve is a HorizontalTableView of the same portrait width, but centered in the screen by the following bitmask (from HorizontalTableViewCell's implementation file):
self.horizontalTableView.autoresizingMask =
UIViewAutoresizingFlexibleLeftMargin |
UIViewAutoresizingFlexibleRightMargin;
This produces a large margin on both sides of the HorizontalTableView, effectively centering the cells, but the individual cell padding remains unchanged.
Any ideas on how I would go about doing this?
(Note that if the following bit mask is used, the cells fly out of view "through the top" of the HorizontalTableViewCell and cannot be seen again, even if the device rotates back to portrait mode).
self.horizontalTableView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
The only way I can think of is to create another view for the landscape mode. Throw your data into a holder object, load the new view, and then reload the data from the holder.
I'll try to explain my problem as clear as I can:
Imagine that we have a UIView in the middle of our screen, and inside of this view, there is, for ex. a UILabel.
Now I want to move the UILabel out of the view, so I make and animation and change the frame of the label to be out of its view. The problem is that now the UILabel is visible in the other view! I want the UILabel dissapearing when it goes out of the view
| _________ |
| | | |
| | label | |
| |_______| |
| |
Now I move label to the left
What is happening now:
_________
| | |
|la|bel |
| |_______|
What I want:
_________
| | |
| |bel |
| |_______|
Make sure that,
parentView.clipsToBounds = YES;
I have a NSTableView with multiple rows and just 1 column.
I want to display table in following format:
----------------------------
| Label - 1 |
| |
| textxtview contents-1 |
| height 20 |
----------------------------
| Label - 1 |
| |
| textxtview contents-1 |
| height 40 |
----------------------------
The height of text view should be fixed and its scrollable
Label & text view text color should be different.
How do I programmatically add labels and textview and set the frames?
You maybe should take a look at NSCollectionView. That's easier to use as you can design the cell view in Interface Builder.