SplitViewController for iPad behaviors - objective-c

I am working with the UISplitViewController in iPad application.
Currently, I found two issues:
1. I can't modify the width of the master view
2. I try to use the customized cell in the master view, but it seems not possible to adjust the width and height of the cell.
Do you have any ideas on the two issues regarding to the standard UISplitViewController?
Thanks,
Mike

1) You cannot change the size of detail view.
Please check the following link, From that link you will get alot of information:
Change the width of Master in UISplitViewController
2) Use the heightForRowAtIndex delegate method. return 60 from that method
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 60.0;
}

Related

UItableview cell not expanding to show text

I have a uitableview cell. I want it to expand and show a lot of text. I set it up with autolayout and constraints. It looks right, but when I run it only shows up to two lines. I don't understand. Can someone point me in the right direction? Thank you.
Here's a link to an image of the setup: https://docs.google.com/document/d/1V8jetMrVDK4ebaconz9PL0y3DnJUqXmPkfyhK-0Nhbc/edit?usp=sharing
From the 2014 WWDC, with iOS 8, if you
Set up autolayout constraints relative to cell.contentView
Use the estimatedRowHeight property
Dont implement -[UITableView tableView:heightForRowAtIndexPath:]
Dont use the rowHeight property
then you can take advantage of self-sizing cells that will expand automatically based on their content.
Check out WWDC '14 under "What's New in Table and Collection Views." You'll only need to watch the first 25 minutes or so.
Implement the following two TableView methods
-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewAutomaticDimension;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewAutomaticDimension;
}
Working with Self-Sizing Table View Cells Here is a useful reference.

Getting Height From a XIB

I'm creating a custom UITableViewCell from an xib. However, the cells don't automatically fit the same height I set in the xib file. Is there a way to get the height of the xib in the heightForRowAtIndexPath so that I can accurately set the height without having to hard code it?
Selecting the UITableView on the storyboard, or view etc, within the interface builder you can set the cell height to match your custom cell nib's height.
Go to the Utilities panel and select the tab as highlighted in blue in the picture below. Set the row height here.
I hope this helps with what you are looking for.
Cheers
You can also use this delegate method of table View
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
//Height same as your XIB of cell
}

NSTableview cell row overlapping issue

I have NSTableView in Xib and connected outlet for that.I am loading the cell data using Key value bindings with NSArrayController.I need to fill the cell rows dynamically.I did it.But I am facing the problem,my Tableview cells are getting merged and lines of cell row are not visible.
Why is this happening,How to solve this.Can anybody have ideas please.
It is happening in 10.7.
It is probably due to cells heights in your table are higher that used in TableView by default. If this is your case:
Evaluate cell height in IB (row height in Size Inspector)
Add delegate method in proper view controller:
(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 50.0; // for example!
}

UITableViewCell as Header or Footer View

I know about UITableView reusable header and footer view
but in my case, i have UITableView Cells, which i need to place also in section headers and also in normal rows
if i use
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
MyCell * cell = [tableView dequeueReusableCellWithIdentifier:#"MyCell"];
// ...
return cell;
}
How does it work out with the reusing? (is the message to be available for reuse even than passed), or does this disable the cell reuse
The cells get dealloc'ed when they go off-screen. So they don't get reused. An easy way to verify this is to subclass UITableViewCell with the following
- (void)dealloc
{
NSLog(#"I got dealloc'ed");
}
and observe the console output as you scroll.
These has always worked fine. You first should create a prototype with that name, or register a custom nib with your custom section identifier. HOWEVER , I noticed this breaks in iOS 7 when you add new sections to the table dynamically. Reverting to a plain non-reusing UIView works. Really a shame!

TableView with dynamically height

I'm programming on objective-c. I have a viewController with tableView. I would like that my tableView has a dynamically height like on a picture below (Tweetbot). How can I make it?
Yes. However its not clear that this table is "short" - it may be that it has a transparent background and only two cells. In any case, to make a short table you would create a UIViewController class with a normal view (ie a UIView). Create a UIImageView and add the image to it (assuming you want a big image), and add that to the view (you could do this in IB). Then create a UITableView of the desired height, and add that too to the UIIView's subviews. Now you have a container view (self.view) with two subviews, the table being the last (so its on top).
Most likly tweetbot doesn't add a UITableView upon a UIViewController. They most likely use the UITableViewController from scratch, giving it a background and (in this case) showing only two cells with a custom height. That is also the "way-2-go" when using the Table View.
You should use -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath method and use if condition or switch case in this method.
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row ==2) {
return 89;//write your image view's height here.
}
return 44;
}