Problems with detail UIView - ios

I'm trying to build my iOS app's interface. Starting over and over with new project i'm still getting a problem with a detail view's controls (see picture).
Here i got the screenshots:
detail view shows when user touch to the UITableView row. You can see the difference between my design and final result on the simulator screen - this is the problem
main xib design
this is how i open the detail view:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Navigation logic may go here. Create and push another view controller.
DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:#"DetailViewController" bundle:nil];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:detailViewController animated:YES];
}

autolayout - that is the source of bugs in my design. I just switched it off on the detail xib and now all controls are in its right places
thank you Rob

Related

Paging view hierarchy broken when dismissing a view

I use the SLPagingView (https://github.com/StefanLage/SLPagingView/) open source library for a paging view based app like Twitter or Tinder.
From some page I open a detail view. When I come back the layout of the paging views is broken.
DetailViewController.m
- (void)backButtonPressed {
[self dismissViewControllerAnimated:YES completion:nil];
}
In fact I noticed that the hierarchy of the app is broken just before the DetailView appears.
SomePageViewController.m
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Perform segue to detailView
[self performSegueWithIdentifier:#"actionDetail" sender:nil];
/* Does not work with a modal view controller either
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main"bundle:nil];
DetailViewController *detailViewController =
(DetailViewController *)
[storyboard instantiateViewControllerWithIdentifier:#"detailcontroller_id"];
[self pushViewController:detailViewController animated:YES];*/
}
I got the Presenting view controllers on detached view controllers is discouragedwarning. I tried to replace self by self.navigationControlleror self.parentViewController.navigationControllerbut both don't work.
Does anyone using this library fix this issue or know a solution?
Fixed.
I modified the SLPagingView library. Add [self addChildViewController:ctr] in initWithNavBarControllers:, initWithNavBarItem: and other life cycle methods.
Check the differences: https://www.diffchecker.com/cnlvslym

How to open view controller from didSelectRowAtIndexPath within storyboard?

I have a storyboard with tabbarcontroller. One of tab bar has a tableview and I want that when the user tap in a row from tableview open a detail view. The problem is when I open detail view tab bar and navigation bar hides... In the storyboard I create the detail view as a new view controller, then I create a new file and referred it to the class of detail view .
The code in didselectrowatindexpath:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
detalleYouTube *dvController = [[detalleYouTube alloc] init];
[self.navigationController pushViewController:dvController animated:YES];
}
Thank you in advance!
This is kinda old but if someone needs to do this here's an easy approach:
You can use add a segue from the view in the tab bar to detalleYouTube, put an identifier to the segue and do this:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:#"segueIdentifier" sender:tableView];
}
Another approach to this is not to use tableView:didSelectRowAtIndexPath but instead use prepareForSegue:sender
the way I did it was:
-(void)prepareForSegue:(UIStoryboardSegue*)segue sender:(id)sender
{
DetailViewController *viewController = [segue destinationViewController];
CustomObject *custObject = [arrayOfObjects objectAtIndex:[self.tableView indexPathForSelectedRow].row];
viewController.objectNeeded = custObject;
}
This example is based on the idea that your detail view controller is connected to your table view controller.
I presume you have the 'Detail' view as part of the storyboard (not in a separate XIB), if so you will need to place a separate NavigationController at the start of the 'Detail' TabBarItem seque.
This page has a good tutorial on what I think your trying to achieve:
http://maybelost.com/2011/10/tutorial-storyboard-in-xcode-4-2-with-navigation-controller-and-tabbar-controller-part1/
Also check these links to a more in-depth Storyboard tutorial:
http://www.raywenderlich.com/5138/beginning-storyboards-in-ios-5-part-1
http://www.raywenderlich.com/5191/beginning-storyboards-in-ios-5-part-2

Problem In UISplitViewController in iPad

I am working on UISplitView Controller. I have used a SplitView controller template of Xcode. Actually i wanted to implement a scenraio in which when i click on table view cell it should add a New Root Controller with a table View into the Navigation Stack.
i did it using the following code
- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NextViewController *nextView = [[NextViewController alloc] initWithStyle:UITableViewStylePlain];
[self.navigationController pushViewController:nextView animated:YES];
[nextView release];
}
It works perfect and i have used the RootView Controller code into the NextViewController so that when we click on New Screen's cell it should update my Detail Screen. But unfortuantely it is not updating my Detail Screen.
What can be the reason ??
Please help friends..
Thanks
To updating your Detail Screen. you need to implement a delegate method of communication between Current RootView controller and Detailview controller.
Best Wishes,

Pushing new view controller from UITableView on a Tab Bar application

I have an app with two bar in it.
one of the tab .xib includes UITableView, when the user select one of the cells, I want to show another UIViewcontroller (.xib file) that includes information about the his selection.
now, I've tried this
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
*)indexPath {
NextViewController *nextController = [[NextViewController alloc] initWithNibName:#"NextView" bundle:nil];
[self.navigationController pushViewController:nextController animated:YES]; [nextController changeProductText:[arryData objectAtIndex:indexPath.row]];
}
and nothing happened, the console is showing no errors at all.
what seems to be the problem?
thanks!
Nothing happened, because your self.navigationController returns nil.
For proper usage of Navigation controller, you must have at least one. For the case of TabBar application, for each tab you must associate not the UIViewController subclass, but UIViewController subclass nested in UINavigationController. That's easily done both in the .xib or in code. Just google for some tutorials.

TableView open´s splitview view´s

Hi
anybody can explain of how to show a splitview when I tap a row from a cell??
or a tutorial of it??
I have a tableview, and i want to display information about that cell in a splitview.
Thanks
I don't think there's a tutorial for that, since you're not supposed to do that.
The split view controller is supposed to be the root view controller of your application, so if you want a pushable split view controller you'll have to write it yourself (or possibly find an open source one).
I want to implement an app that when it press a row from a table, it will open a splitviewcontroller that show the information
about the selected cell in the "detail´s splitview" , and all the info of the table in the "rootview".
I have copy to my project the
DetalviewController.h/m
RootViewController.h/m
DetailView.Xib
files from the splitview template.
And add this code to my tableviewcontroller:
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//Initialize the controller.
if(split == nil)
split = [[RootViewController alloc] initWithNibName:#"split" bundle:[NSBundle mainBundle]];
//Pass the current row number to the sub view controller.
split.number = indexPath.row;
//here is my problem, i cant add the new view, and it crash
[self.view addSubview:[split view]];
}
enter code here

Resources