What is the best way of having a block of screen run by it's own view controller, whilst the rest of the app runs as normal, switching between views etc.
So the block of screen would be a permanent fixture (tho could be hidden), while the user can switch between tab, push new views etc?
Is there a way to programmatically attach a view to a view controller to do this, or is there some other method?
-----------------------------------------
| |
| nav bar or tool bar |
-----------------------------------------
| |
| |
-----------------------------------------
|view to be attached to view controller | < this block stays even when in other views
-----------------------------------------
| |
| |
| |
| main bit of the view |
| changes according to tab |
| |
| |
| |
-----------------------------------------
| | | | | |
| | | | | | < tab bar
| | | | | |
-----------------------------------------
Instead of attaching to view controller, create the view in appDelegate or a singleton instance of the view and whenever a new view is pushed/switched, this view is moved to the front by writing
[self.view addSubview:_yourStaticView];
in the view did load methods of each view controller class. A single UIView controller has a stack, so it cannot render multiple views at the same time, it's either one or the other. Whenever you want to remove this view, write:
[_yourStaticView removeFromSuperview];
You can change the contents of this view just as you would with a UIView!
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 want create one page that has 3 horizontal (right to left) Scroll in top & middle & down page.
in each scrollview there are many image like this :
----------------------------------------
| ------- -------- -------- |
| | | | | | | | Outside the box is scroller!!!
| | | | | | | |
| ------- -------- -------- |
----------------------------------------
in any page of scroll exist 3 image .
I want when change page of scroll images that exist this page changing!!! (like Scroll in IMDB application)
I can create Scroll and I can read many images from URL but I can not connect these!!! :(
please tell me about.
Check iCarousel brilliant lib for doing stuff like that. It includes a lot of examples and compatible with iOS5.
This might work for you:
A. Create a UIView to hold 3 UImageViews to contain the 3 images.
B. Add the UIView as the contentView of the UISrollView.
C. Use a combination of UIPageControl and UIScrollView.
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;