Calling modalTransitionStyle from UITableViewController - nothing happens - ios

I finally managed to trim my code and put all the TableViewController-Methods in a separate class (away from my ViewController). I had many problems which I already solved but there is one that puzzles me.
When a selection in the table occurs, I previously loaded a modalViewController, which worked fine. But now, as I put all the Table-methods in a separate class, the modal view simply does not load. It calls the function, and steps through it nicely when I select a row in the table, but there is no view loaded on the screen of my iPhone?!
Here is the code:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
TaskViewController *taskViewController = [[TaskViewController alloc] initWithNibName:#"TaskViewController"
bundle:nil
task:[listOfEntries objectAtIndex:indexPath.row]];
taskViewController.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentModalViewController:taskViewController animated:YES];
[tableView deselectRowAtIndexPath:indexPath animated:NO];
}
any suggestions?

Problems loading the NIB file? Not returning self from TaskViewController's init method? Are you sure taskViewController is not nil? Maybe you should call this on a parent navigationController? Are you setting UIModalPresentationFullScreen as the modal presentation style?

Related

Segue not working on tableView

Okay, I got this strange situation.
I have multiple tableViews in my project, but only on one tableView I can click on an item and perform an action (go to next segue).
On the other tableViews I can click what I want but nothing happens.
I removed the one that was working and made the link again, and it was still working. What am I missing?
I'd like to suggest to you to use the delegate method to handle item selection:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Here you can do something with, e.g. push a view controller:
id vc = [self.storyboard instantiateViewControllerWithIdentifier:#"myVC"];
[self.navigationController pushViewController:vc animated:YES];
}
In most cases it is more comfortable to implement and maintain table views with delegates instead of using segues.

Ios-Segue to a UIViewController not happening after using pushViewController to load TableViewController

I am currently working on an IOS app to browse the folders on a remote computer and display the pictures. Now in order to browse the folders I am using the same table view and updating its cells, each time the user presses on a tile. Now after getting to the final list of contents(Images), I am trying to use a segue to navigate to UIViewController to display the Images. But I am getting an error: "segue not found".
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
// Fetch device
self->browseObjID = [avObjArray objectAtIndex:indexPath.row];
if([self->browseObjID isFolder])//To load same table view for browsing the folders
{
ContentL1TableViewController *targetViewController = [[[ContentL1TableViewController alloc] initWithMediaDevice:_devSelected andObjectId:self->browseObjID ];
[[self navigationController] pushViewController:targetViewController animated:YES];
}
else
[self performSegueWithIdentifier:#"DisplayImage" sender:self];// display final image
}
You can only segue from a view controller that is created by a storyboard.
I'm assuming that you defined this TVC in a storyboard initially but that is only the first one.
When you are going to the subsequent TVCs you are creating these using alloc init and so they don't have a storyboard with a segue defined.
You should either create your image view controller using a xib file and load it from the xib or create it in code. Both would be easier.
Or you could define a "circular" segue that goes from the TVC back to itself and use this instead of creating one using alloc init all the time.

UIWindow not getting set when pushing UIViewController from Nib

I'm trying to do a very simple pushViewController with a view controller created from a nib.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
ServiceDetailViewController *serviceDetail = [[ServiceDetailViewController alloc] initWithNibName:#"ServiceDetailViewController" bundle:nil];
serviceDetail.employee = _employee;
[self.navigationController pushViewController:serviceDetail animated:YES];
previousSelectedRow = indexPath;
}
If I return the window of the serviceDetail view controller within its viewDidLoad or anywhere else inside of its functions it is null. When I return its window right after pushViewController it is fine.
My viewDidLoad is normal. I am calling super.
It seems like this is either something silly that I'm overlooking, a problem with my splitViewController setup, or a bug in xCode 4/ARC.
I understand I may need to provide a lot more code but I'm hoping someone might have an idea.
viewDidLoad is called right after a view is loaded into memory, but before the view is added to the view hierarchy including the backing window. The viewDidAppear method is called right after being added to a window. Maybe your code needing the window value will work better in that method.

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.

Split View like Settings

I have created a basic Split View and instead of loading a UIView on the right hand side, I have loaded a UITableView. The UITableView is made up of UITableViewCell's and what I want to do is when I click on the Cell, it loads up another UITableView for selection much like that in the iPad settings. However I cannot the UITableView to load after selection.
Any ideas how to achieve this? I've seen similiar questions and had a look at the apple site with uitableviews but haven't been able to solve the issue as they're geared towards iphone which doesn't have the split view.
On the didSelectRowAtIndexPath i've loaded it like so which other apps have done but to no avail.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if(indexPath.row == 0)
{
LevelTwoController *leveltwoController = [[LevelTwoController alloc] initWithNibName:#"LevelTwoTableView" bundle:nil];
[self.navigationController pushViewController:leveltwoController animated:YES];
[leveltwoController release];
}
}
Another thing also is my leveltwoController is a UITableViewController and I just keep getting this import error literal-pointer#_OBJC#_cls_refs.
Your main view that has the TableViewController needs to be controlled by a UINavigationController, and then you could push the subsequent views onto the view stack. My guess is your current implementation is having self.navigationController be nil so nothing is happening.
If you take a look at some of the basic xcode templates that use uinavigationcontroller's you should be able to figure out the proper path.

Resources