I have a question,In my View Controller i have dragged a UIView just above tableViewCell inside tableView which contains 3 textFields,above tableView i have taken a collectionView . My question is how that when i scroll the whole view controller to top i want to hide collection view as well as that which which contains those 3 textfields.And also create one new textfield and also position of tableview will be just below new textfield and when scroll the view controller down then that new textfield will hide and other things again show with same position as it is before scrolling.I have also tried func scrollViewDidScroll(_ scrollView: UIScrollView)but did not get it working Anyone help me with this.
Related
I have a UITableViewController. Each cell in the table has a segue to present another UIView modally.
When I click on a cell in the UITableView, it brings up the other UIView.
But I put the UITableViewController in a Navigation Controller, nothing happens on the first click to the cell, and the UIView shows up on the second click.
Does anyone know why putting the UITableViewController in a Navigation Controller cause the first click to do nothing?
EDIT:
It seems that the focus is not initially on the table view. When I first click the cell, the focus on the tableview, and the second click goes to the cell.
I used storyboard.
Here're some screenshots:
This is the setup of the views
This is how the table cell is connected to second view controller
I have a horizontal UITableView and it has a subclass of a UITableViewCell. I am trying to have an animation where if someone taps on the UITableViewCell the cell does a backflip animation and resizes into a modal view. How and what is the easiest way to do this?
For this you can actually perform exactly what you want using UIView's class method:
transitionFromView:toView:duration:options:completion:
http://developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/uiview/uiview.html
You could do the following:
Create a clone of the UITableViewCell that has been pressed
Overlay it on the table view at exactly the same position as the pressed cell
Call the method above using the 'from' view as the cloned cell view and the 'to' view as the new 'modal' view (a view that fills the screen).
I recommended that you create a clone otherwise the cell is removed from the tableview:
The starting view for the transition. By default, this view is removed from its superview as part of the transition.
edit: I forgot to mention, the animation that you're looking for is UIViewAnimationOptionTransitionFlipFromBottom
I have a screen where I want to display the details of some product. I'm using storyboards.
I have done this using a tableview with static cells, but static cells can only be done within a tableview of UITableViewController. And the problematic point is that I also want to have a Imageview within this controller. this is not possible as the tableview of a UITableViewController take all the screen size.
So I'm doing the Imageview as a subview of the tableview.
I'm wondering if it is the right way to do it, there are similar issues on stackoverflow but none is corresponding to my use case (storyboard + tableviewcontroller + staticcell + sub view)
Without writing any custom code, you could either:
Put a UIImageView in the table view's header or footer view.
Create a static cell and put the UIImageView in that. Table cells don't have to be uniform length, you could make it taller than the other cells if needed.
You can have your subclass of UITableViewController. After you initialize it take its view (tableView) and add it as subview to some other view controller. This way you can set the frame of tableView to occupy the bottom of the (top containing) view controller. To the same view controller you can add additional subviews like UIImageView and position it on the top. The only problems you will encounter might be related to missing notifications to your UITableViewController subclass (viewWillDisappear, viewDidDissappear, viewWillAppear, viewDidAppear, ...). But you can forward them to from your top view controller. Or you could use methods from iOS 5 to add subclass of UITableViewController as a child view controller and position it as you wish. But this is useful if you plan on supporting devices with iOS 5.0+.
See documentation of method in UIViewController:
- (void)addChildViewController:(UIViewController *)childController __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0);
Use a UITableView as a property of the viewController and add it to vc.view, rather than subclass a UITableViewController, then set its frame as you like
Add the imageView to vc. If you need to put it on top of the UITableView, for example, add it as the TableView's header.
Say for example I have a tab bar controller where one of its views is a tableviewcontroller, and another one is some other view. The other view has a button in it that when pressed, should make it so the tableview (which is not on the screen while you're pressing the button) repositions itself so that some specified cell is now the top one being displayed when the tableview is again displayed.
My question is this: can I just call [myTableVC.tableView scrollToRowAtIndexPath:someIndex] from inside the other class when the button is pushed? Or does the view actually have to be on the screen when scrollToRowAtIndexPath is called for it to change the top cell that will be displayed?
You may be able to, but you probably shouldn’t—calling view or tableView on an offscreen view controller may cause its view to get loaded into memory unnecessarily. Just set a property—a CGFloat or whatever—on the view controller for the scroll position that it should be at when it appears, and scroll to that position in the controller’s -viewDidLoad or -viewWillAppear:animated:.
I have a scrollview that has a page control. The scrollview contains 3 views. Each view contains a view controller. In one of my view controllers I press a button and I want the scrollview to scroll to a specific location. But Im not sure how to accomplish that since the button is not in the UIScrollview but in one of the view controllers. Could anyone point me in the right direction with this? I have spent a lot of time trying to follow the view hierarchy to see if I can send a message to the scrollview for it to scroll. Any help is appreciated.
You can:
Add a delegate in your 3 inner View
Controllers that points to the View
Controller that holds your Scroll
View.
Create a method in the View
Controller that holds the Scroll
View that will call [scrollView
zoomToRect:] when called.
Access it from your 3 inner View
Controllers using the delegate.
If you need more information about delegation. check what is Delegate in iPhone?.