resize UItableView - iphone

i use this code
- (IBAction)gotostatuttableviewcontroller:(id)sender
{
[self.statutsField resignFirstResponder];
StatusTableViewController *statuttableview =[[StatusTableViewController alloc]initWithNibName:#"StatusTableViewController" bundle:nil];
statuttableview.Flynumber=statutsField.text;
[statuttableview.Flynumber retain];
[self.navigationController pushViewController:statuttableview animated:YES];
}
and this is my interface in interface builder http://hpics.li/19cc67b
But when i build , i have this
http://hpics.li/188d87e
Why the tableview don't have the same seize that i puted in interface builder ? It's becaus it' a UItableViewcontroller class and not UIViewCotroller ?
#CharlieMezak i do it and now i have this error
Terminating app due to uncaught
exception
'NSInternalInconsistencyException',
reason: '-[UITableViewController
loadView] loaded the
"StatusTableViewController" nib but
didn't get a UITableView.'
in this line ( pushviewcontroller)
StatusTableViewController *statuttableview =[[StatusTableViewController alloc]initWithNibName:#"StatusTableViewController" bundle:nil];
statuttableview.Flynumber=statutsField.text;
[statuttableview.Flynumber retain];
[self.navigationController pushViewController:statuttableview animated:YES];
Thank you

Look at your nib file. Check that the File's Owner view outlet is connected to the top level UIView and not to the UITableView. If it's connected to the table view, then the table view will be treated as the view controller's view. The containing views will be ignored.

Try setting the frame of the UITableView in viewDidLoad.

Related

While transition the page after click, screen is going black

here is my code:
I using storyboards
NewsDetailViewController *newsdetail=[[NewsDetailViewController alloc] initWithNibName:nil bundle:nil];
newsdetail.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:newsdetail animated:YES];
I have a collectionview i fetched some datas from api and put them to the cells of collectionview. I want to get details of items that i clicked on cell but after click details doesn't work but black screen is coming.
here is my all output :
2013-06-17 14:20:30.288 xproject[7511:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/sezgindemir/Library/Application Support/iPhone Simulator/6.1/Applications/67BC91AF-5091-4F39-A2BD-CA7E1DD0FEF0/xproject.app> (loaded)' with name 'NewsDetailViewController''
*** First throw call stack:
(0x1c99012 0x10d6e7e 0x1c98deb 0x236ef9 0xfb7e7 0xfbdc8 0xfbff8 0xfc232 0x107c25 0x3073a3 0x104ee3 0x105167 0x1051a7 0x4c3d 0x51c42f 0x52e182 0x52e394 0x10ea705 0x12893c 0x1289ac 0x10ea705 0x12893c 0x1289ac 0x2e21d3 0x1c61afe 0x1c61a3d 0x1c3f7c2 0x1c3ef44 0x1c3ee1b 0x1bf37e3 0x1bf3668 0x1affc 0x25ed 0x2515)
libc++abi.dylib: terminate called throwing an exception
(lldb)
Is the xib for NewsDetailViewController in storyboard or separate xib?
If it is a separate xib, make sure your xib name is NewsDetailViewController.xib. Then it should work.
If the nib is in storyboard the
first set the storyboardID of the xib to NewsDetailViewController and then use
NewsDetailViewController *newsdetail=[[self storyboard] instantiateViewControllerWithIdentifier:#"NewsDetailViewController"];
newsdetail.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:newsdetail animated:YES];
You're not loading view controller properly.
Try this code:
UIViewController *vc=[[self storyboard] instantiateViewControllerWithIdentifier:#"NewsDetail"];//you have to give it this name (or any) in the storyboard
[self.navigationController pushViewController:vc animated:YES];
Make sure you have a uinavigationController controlling self
I think you missed to provide the NibName
Your code
NewsDetailViewController *newsdetail=[[NewsDetailViewController alloc] initWithNibName:nil bundle:nil];
It should be
NewsDetailViewController *newsdetail=[[NewsDetailViewController alloc] initWithNibName:#"YOUR_NIB_NAME" bundle:nil];
Use this -
NewsDetailViewController *news detail = [[NewsDetailViewController alloc] init];

Present UIPopoverviewcontroller

I am working on a app, which uses UIPopoverController, I am getting a problem in presenting that popover, I have a UIView which is added on self.view, and a tableview added on that view, that table view has a custom cell, which includes a UITextField, on didBeganEditing method I need popover to open.
Here is the code:
table = [[UITableView alloc]initWithFrame:CGRectMake(textField.frame.origin.x,textField.frame.origin.y,200,100) style:UITableViewStylePlain];
table.tag=3;
[table setDataSource:self];
[table setDelegate:self];
[table reloadData];
UITableViewController *tableViewController= [[UITableViewController alloc] initWithStyle:UITableViewStyleGrouped];
tableViewController.tableView = table;
popOver= [[UIPopoverController alloc]
initWithContentViewController:tableViewController];
[popOver presentPopoverFromRect:popRect inView:cell permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
I will getting following exception
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated:]: Popovers cannot be presented from a view which does not have a window.'
here you present popoverview in the cell and give the Rect to popover of UITableViewController and so you get this error.. here it have not view hierarchy so its not get window and crashed here just follow the view hierarchy.

Swapping views inside a tabview controller

I have an app based on a tabBar controller. Within a certain view I'd like to add swipe gesture recognition and swap the current view with another one (which is not part of the tabBarController array). I have tried:
- (IBAction)swipeLeftDetected:(UIGestureRecognizer *)sender
{
//Does not work
UIViewController *DesiredViewController =[[UIViewController alloc] initWithNibName:#"DesiredViewController" bundle:nil];
DesiredViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:DesiredViewController animated:YES];
[self.view addSubview:DesiredViewController.view];
}
but the program crashes. The error I get is related to a SegmentedControl which is present in the next view but is absent in the current one. The views independently work perfectly!
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason:'[<UIViewController 0xa355fb0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key X_SegmentedControl.'
I don't understand what I am doing wrong.. I want to swap the views completely rather than putting one on top of each other. Any advice please? Thanks
instead use this
-(IBAction)swipeLeftDetected:(UIGestureRecognizer *)sender
{
DesiredViewController *objView =[[DesiredViewController alloc]initWithNibName:#"DesiredViewController" bundle:nil];
objView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:objView animated:YES];
[objView release]; // use release if using Non-ARC
}
The problem is not about the transition.
You are loading a view controller from a NIB.
A view controller is usually subclassed, so (assuming that your nib is configured correctly and you have .h and .m implementation file for your DesiredViewController subclass) you should init like this:
DesiredViewController *controllerInstance =[[DesiredViewController alloc] initWithNibName:#"DesiredViewController" bundle:nil];
The exception is because you probably have a segmented control inside your view controller subclass, Xcode is trying to link this control to the outlet on the view controller, but this outlet doesn't exists (because you are allocating an UIViewController not the subclass).

Pop to root then perform segue on iPhone

I am running on iOS 6.0 storyboard enabled
I have a NavController linked to a TableViewController.
This TableView can segue to AViewController or BViewController.
When I am in A, I want to pop back to the root and perform segue to B with this line :
UINavigationController *nav = self.navigationController;
[nav popToRootViewControllerAnimated:YES];
[nav performSegueWithIdentifier:#"GoToB" sender:self];
I checked the storyboard, GoToB do exist and is linked from the TableViewController to BViewController
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<NavMainViewController: 0xb921fa0>) has no segue with identifier 'GoToB''
What am I missing ?
The segue will be attached to the view controller you pop to, not nav which is the container view controller that contains it. So this would be closer:
UINavigationController *nav = self.navigationController;
[nav popToRootViewControllerAnimated:YES];
UIViewController *rootVC = [nav.viewControllers objectAtIndex:0];
[rootVC performSegueWithIdentifier:#"GoToB" sender:self];
But, I think the problem here will be that the pop animation will conflict with the segue. Doing the pop with ...Animated:NO might fix it, but I think it would be more correct (and more robust for animations) to perform the segue from the rootVC.
rootVC would implement viewDidAppear as follows:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
if (!self.isBeingPresented && /* any other condition that makes you want this */) {
[self performSegueWithIdentifier:#"GoToB" sender:self];
}
}

iPhone: App crashes when I click on a cell in table view

Compiling my application works—everything is fine. The only errors I get are by deprecated functions (setText).
The only problem is now, is that when I tap on a cell in my table, the app crashes, even though it's meant to push to the next view in the stack.
Any solutions are appreciated, if you need any code, just ask.
Also, how can I only make sure that one cell goes to only one view? For example:
When I tap on CSS, it takes me to a new table with different levels of CSS. WHen I tap on an item in that new view, it comes up with an article on what I just selected.
Regards,
Jack
Here's my code at the didSelectRowAtIndexPath method:
-(void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.row==0){
NextViewController *nextController = [[NextViewController alloc]
initWithNibName:#"NextView" bundle:nil];
[self.navigationController pushViewController:nextController
animated:YES];
[nextController changeItemTable:[arryClientSide
objectAtIndex:indexPath.row]];
}
}
#end
(as requested in the comments).
When we create new UIViewControllerSubClass with xib-interface, xib file is created as sourcecode.xib (can be seen in get info of that xib file): Change sourcecode.xib to "file.xib" and see the magic :)
Terminating app due to uncaught
exception
'NSInternalInconsistencyException',
reason: -[UIViewController
_loadViewFromNibNamed:bundle:] loaded the "NextView" nib but the view outlet
was not set.'
Open NextView with Interface Builder
Set Class value at : "NextViewController" to your File's Owner
Connect the View outlet (Ctrl click and drag - a blue line should appear - from the File Owner to the UIView and select "view" in options)
you need to update your code like this :
-(void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.row==0){
NextViewController *nextController = [[NextViewController alloc]
initWithNibName:#"NextView" bundle:nil];
[nextController changeItemTable:[arryClientSide
objectAtIndex:indexPath.row]];
[self.navigationController pushViewController:nextController
animated:YES];
}
else{ }
}
try using this code...
Error description from comments:
Terminating app due to uncaught
exception
'NSInternalInconsistencyException',
reason: '-[UIViewController
_loadViewFromNibNamed:bundle:] loaded the "NextView" nib but the view outlet
was not set.'
If your view controller is loaded from nib file and its view is not set exception then exception is thrown. So when you create your view in IB you must connect view outlet to your view controller object (likely - file owner in IB).
Edit: So basically in IB in your nib file you need to do the following:
1. set file owner's type to NextViewController
2. connect NextViewController's view outlet to a View object
release that NextViewController you alloc!
[nextController release];
It's leaking.
Don't use IB. Instead, make alloc init with nothing, then in load view:
self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];