Change detailview according to masterview in UISplitViewController - ios

I have a UISplitViewController which has a searchfiled in the first row of its master view which is a tableview as we all know.
And my detail view contains a collectionview. I have to update my collectionviewcells according to the seacrhfield text. So how i update collectionview cells just when editing begins in searchfield.
I want to show a activityindicator too when user started searching.
So basically i want to control DetailViewVontroller's properties from MasterViewController's class whenever i want. Is it possible?

You can use
[self.view addSubview:lbl]
to add the label to your tableview controller's view.
If you want to replace the view controller,
take a look at the showDetailViewController:sender: method in this:
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISplitViewController_class/index.html

Related

Adding a collection or tableview or custom view to a scrollview in ios 8

I have a UIScrollView with lots of sub views on the scrollview. I have a picture, buttons, textfields and the like that all work fine.
Now I want to add a comment section below all this that "acts" like a UITableView.
What is the best way to accomplish this? I want the comment section to load 10 comments when that part of the view appears, and continually add 10 more comments when the 6th comment appears. There should also be an activity indicator too.
I know you can't put a collection view or tableview with a scrollview (according to Apple) as their are inherited from UIScrollView. And making the whole view controller a table view or collection view is tough since I have so many subviews and actions all linked up already.
What's the best approach?
Thanks.
You can create a new table view controller and load (add subview on cell content view) your current controller as first cell of table view controller.

iOS picker view as default input method

I have labelA in my custom tableview cell. When I click on the label I want picker view to be shown in the bottom of the screen in order to choose available options.
My question is: Do I actually need drag and drop PickerView into my view in storyboard or I can just invoke it as default input method? (Same as keyboard for text field)
If yes, how do I do that? - All I want when label is clicked show picker and hide it on when selection is finished. Could you please provide me some examples?
I am developing under swift but iOS example is fine as well.
Thanks for any help!
Edit:
Well label is not principle, I can use just input trigger from the cell directly. Idea after click show picker view and hide it after selection.
What I mostly do is use a UITextField and set the inputAccessoryView property to an instance of UIPickerView. This will display the UIPickerView once you tap on the UITextField instead of the default keyboard.
You can instantiate the UIPickerView all in code in your tableView:didSelectRowAtIndexPath method. You can either add it to your view controller using self.view addSubView. You will have to write code to place it properly on the screen with your table view. You might want to resize your table view so it shrinks and your picker view is shown on the bottom of your view.
An easier way could be to show a modal dialog with your UIPickerView already set up.
UPDATE
Create an new controller that is of type UIViewController.
Drag a UIViewController onto your storyboard and give it the type of the above controller and a storyboard id. I use the name of the UIViewController created.
Add your picker view to that and configure your data source.
Create a delegate for the option selected and have it return the item selected.
- (void)selectionMade:(NSString *)selectedValue;
In your table view controller, implement that delegate method above.
In tableView:didSelectRowAtIndexPath, load that view controller and show it.
[self.storyboard instantiateViewControllerWithIdentifier:#""]
Your delegate method will get that value and you can retrieve the cell using tableView.indexPathForSelectedRow.
Update you cell accordingly.

Adding elements to top and bottom of UITable View Controller

I am new to objective C. I have a small app where I have used a UITableviewcontroller(TVC). I need to add four elements.,label and button above TVC and a label and button below TVC. But it is allowing only to add 2 elements., one above TVC and other below TVC. Also added element is occupying the entire width of screen. Can I overcome this restriction???
Customize the table view cell – instead of using the default style of table view cell.
this link is helpful you with sample project
http://www.appcoda.com/customize-table-view-cells-for-uitableview/
These two are tableview properties.
tableHeaderView
tableFooterView
By using the above properties you can show your own custom view on top / bottom of table view.
sample code
[self.tableView setTableHeaderView:yourHeaderView];
[self.tableView setTableFooterView:yourFooterView];
Write this code in viewDidLoad.
UITableViewController is kind of a screwed up class, in my opinion. A UITableViewController can only manage a table view, and nothing else. If you want a more complex layout where you have a table view on part of the screen, and then other view objects elsewhere, you can't do that with a UITableViewController.
However, with iOS 6 and later, there is a pretty easy solution.
You can embed a UITableViewController as a child view controller of another view controller.
What you do is to create a parent view controller with everything you need. Then you create a container view on your parent view controller and size it to contain your table view. Then you create a separate scene in your storyboard that defines a table view controller. Finally, you control-drag from your container view to your UITableViewController, and create an embed segue.
I have a project on github that demonstrates this technique:
Demo project using UITableViewControllers as child view controllers

Can't change the size of a TableView in Interface Builder

I'm trying to change the size of a tableView I have in interface builder and can't seem to. When I first started the app I could drag it around and stretch the sides but all of a sudden I can't adjust it. I tried to delete my tableView and add a new one but the same thing happened. Thanks in advance. Here's what I see when I try to change the size:
if your using a UIViewController you can drag and drop a tableView and can place in a custom position you want. but if your using a UITableViewController you cant move the tableView to your custom position. if you want to do it in UITableViewController you can do like below
if you want your tableView content should show from a point, that you want you can do this way,
[self.tableView setContentInset:UIEdgeInsetsMake(100,0,0,0)];
else if you want set your tableView to a frame in UITableViewController you do this way,
- (void) viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
self.tableView.frame = CGRectMake(0,100,320,300);
}
hope this will help you.
What kind of view controller are you using to manage your table view? Since you show "prototype cells", I'm guessing it's a UITableViewController. Those are built to fill the entire screen with a single table view (which has always annoyed me.)
Starting with iOS 6, though, you can create a "container" view in another view controler, and then drag an embed segue from your container view onto the table view controller. That does all the housekeeping to make the table view controller a child view controller of the other one, and then you can make it whatever size you want.
If you don't want to use a UITableViewController as a child of another view controller, you can use a regular view controller and wire up the data source and delegate methods yourself. However, things like static table views and prototype cells don't work then.
Hopefully this helps someone still coming across this problem. What I did was make sure the UIViewController had a UIView as its direct child, then dragged the UITableView as a child of the UIView, this allowed me to resize the UITableView.

Using UINavigationController for inner UIView

What I have an iphone screen with a main UIView which has another UIView inside it with the size of 280x280 which has a tableview inside it. What I want is that when a user selects any row of that table inside that inner UIView, it pushes the user to another 280x280 UIView, so basically the main view is going to be fixed but only the inner view changes. What's the concept that can make this happen ?
Thanks in advance.
I think that user994813 wants to say this:
A UINavigationController controls the total screen. So, only pushing
and popping a 280x280 field is not possible.
The best way to achieve this would be to let a UITableViewController
be the controller of the main view. Use this as delegate and datasource
for your 280x280 tableview.
When a user selects a row, use a transition to let the tableview
disappear and the other 280x280 view appear. In other words, I fear
that you have to do this manually, although it's not very hard.
If you need a NavigationBar, create it manually in interfaceBuilder.
you need to create two 280*280 view one for your tableview and another for other(push view) and whenever you select table row you need to hidden true first view and hidden false second view(pushview).

Resources