UIScrollView does not scroll when an object is inside - objective-c

I made a UIScrollView inside a UIViewController I have like 5 ViewControllers my problem is in the 4th one.
The UIScrollView I made does scroll when I put notting it it (so no label no button, no objects at all) but when I put even a label (or anything) in the UIScrollView it stops working.
Edit:
I have try'd making the same thing in a new project, for some reason it does work I think it has something to do with the fact that it is in the 4th ViewController and the new one I made, was made, in the First automatically made viewcontroller.
I do not yet have a answer please help.
My code:
viewcontroller.h
#import <UIKit/UIKit.h>
#interface viewcontroller : UIViewController
#property (weak, nonatomic) IBOutlet UIScrollView *ScrollerMdon;
#end
viewcontroller.m
#synthesize ScrollerMdon;
- (id)initWithNibName:(NSString *) nibNameOrNil bundle:(NSBundle *) nibBundleOrNil
{
self = [super initWithNibName: nibNameOrNil bundle:nibBundleOrNil];
if(self)
{
}
return self;
}
-(void)viewDidLoad
{
[ScrollerMdon setScrollEnabled:YES];
[ScrollerMdon setContentSize:CGSizeMake(320,1000)];
[super viewDidLoad];
}
#end
In xcode viewcontroller connection inspector my outlet ScrollerMdon is connected with *Scroll View(*which I inserted in my viewcontroller)
In xcode UIScrollView connection inspector my Referencing outlet ScrollerMdon is connected with viewcontroller.
Please help me I have been trying to solve this for 5 hours.. I can't stand it anymore.
Edit:
I try to make it possible for a single viewcontroller to hold like 17 textboxes I see no other way than doing it with a UIScrollView if there are any suggestions I would be really happy.
Edit2:
I have try'd to make it all aggain putting the same class on a different view controller and the other way around, I kinda rewrote the code and everything it's exactly the same as what I made in the other project but it does not work.(when an object is inside..)
2 foto's of my program.
Srry for the small and bad images, for some reason they moved without my permision but it is enough information I guess.(I use VMWare 8 with os x leopard on it)
foto 1
foto 2
Me Scrolling without items:
imgur.com/cd16I
Me desperately Scrolling with items:
imgur.com/hNUl1
Since I can only post 2 hyperlinks you have to open these yourself.
PS. please upvote this if you do not know the answer for I need a answer and there will probably be more viewers if it gets upvoted, ty.
Edit3:
I am now copying my entire code and build of the app in a different project hope this wil work :S.

I had the SAME exact problem that I ran into yesterday. Drove me nuts for hours... This was a brand new project that I just started like a week or so ago.
The thing is, I had another project that had the exact same setup essentially that I had started last summer that has no problems. Tabbed application, VC that has a UIScrollView with many uiviews, labels, images etc... works great.
So what changed from that project to this project? The version of Xcode that I started the project out in. The project from last summer did NOT have the AutoLayout enabled as an option. This new one did ( Xcode 4.6 ).
If I turn off "Use AutoLayout" for the entire project it works fantastic.
In the Utilities panel, click on the File Inspector tab. In the section for "Interface Builder Document" you'll see a checkbox for "Use AutoLayout". De-select that and re-build your app. Just found this trick not more than 10 minutes ago for my own project -- works great.
Hope this works for your project... good luck!

I found the solution it might not be the perfect solution but it works.
The problem seemed to be somewhere in my first project since I could make it work in other projects,
so I copy'd my entire project to a different project and this way it worked.

This solution won't explain what is wrong but I think it will solve your problem.
Copy the elements from the new project you created to the old one and replace the affected view controller. Copy also the class.
There must be something wrong with your connections but with the info you provided is impossible to check.
If that doesn't work then it must be something in the navigation (doubt it) or in some custom code you have on the class (very difficult if all the code you have is in the viewDidLoad as you've shown).

Related

CoreData, NSArraycontroler and NSTable, NSTable does not update after object added

Still learning so I could really use some help from you more seasoned folks. I'm learning more about the MVC model and trying to implement this with CoreData. My test application has the AppDeligate, MainController and a MocManager. All CoreData stuff is moved to the MocManager.
On the xib I have an NSTable, an NSArrayController and a NSButton.
In MainController, I have an instance of the MocController with a simple method to add a name to the database.
-(IBAction) addPerson:(id)sender{ [manager addperson:#"Sam"]; }
This method is called when the NSButton is pressed. Pressing the NSButton does add the name to the database, however it does not update the table. If I close the App and reopen, the name will appear in the NSTable, so the adding method is good and is working.
I tried both of the following (Separately):
Linked the NSArrayController to MainController through an IBOutlet
Linking the NSArrayController to MocManager through an IBOutlet
In both cases, I used [ArrayController rearrangeObjects] method after the save - the NSTable still does not update.
--[EDIT]----
Appears to be a bindings issues as pointed out by Vadian - but I cannot seem to figure out where/why.
In a previous App I successfully moved the coredata stack in to the MainController, all bindings appear to be working properly.
For this test App, I moved the coredata stack to it's own controller - "MocManager".
In MainController I created an instance of MocManager with:
MocManager* Manager; //This is in .h
manager = [[MocManager alloc] init]; //This is in .m init method
Data loads in to table on startup, but will not sync when using addPerson method in MainController.
Also, I connected an NSButton directly to the remove method on the NSArrayController - the items are removed from the NSTable but not saved, they reappear when App restarted. This all further points to the bindings issue.
Any pointers/thoughts/help would be greatly appreciated.
--[EDIT - SOLUTION]-----
Thanks to Vadian for pointing me in the right direction, it was in fact my bindings.
In the NSArrayController in the XIB I needed to bind it properly to the correct ManagedObjectContext. In my case it is to manager.ManagedObjectContext.
Hope this helps someone.

Error loading .xib - application crash

I am banging my head against a brick wall. I am trying to push a view onto a UINavigationController in the usual manner:
[[self navigationController]pushViewController:vc animated:YES];
When I do this the app crashes with the following error:
__CFStringEncodeByteStream + 17
Thread 1: EXC_BAD_ACCESS (code=2,address=xxxxx)
Now, I have replaced the ViewController in question with a template provided by XCode and I do not get the error so the issue must be with my UIViewController class. Furthermore, if I replace the nib name with that of the template UIViewController class it works .i.e.
MyViewController *myVc = [[MyViewController alloc]initWithNibName:#"XCodeViewController" bundle:nil];
This leads me to think that the issue is actually with the nib and not the class itself. I have checked through all the connections and there are no errors or warnings.
Hopefully somebody can help.
Thanks
I was dealing with a very frustrating bug similar to yours, and everything was in place.
The newly created xib was added to the Bundle resources, no nil pointers or released pointer, NSZombieEnabled was set. The File's Owner was set to the correct ViewController as well
After sitting down with my senior for 30 minutes, we finally realized what was wrong -
In the newly created Xib, even after you assign the File's Owner to the ViewController there is an additional step which you need to take.
You need to have the main View's referencing Outlet set to the File's owner as well. The easiest way to do this is to Drag the "+" sign on the referencing outlet(From the Connections inspector) to the "File's Owner" in the Document Outline. After this you just need to click on "view" which pops up and you should be good.
Hope that helps you or anyone else facing the same problem
Need more info to answer, I can give few possibilities.
Check if the class name is mapped properly in your identity inspector.
And check your connections too. If your view is mapped in xib., etc.
If your running the app in OS below 6.0 & built with features such as Auto layout, it leads to crash.
There are multiple possibilities.
Hope this gives an insight.
Check if your nib is added to the application bundle. You can do that by selection you project file->Build Phases->Copy Bundle Resources.
If it is not there, add it.
I had the same issue yesterday and this was the problem.
I hope it helps.

UITableViewController Files

Following a tutorial exactly, I created files that extend UITableViewController. The problem is that his uitableviewcontroller.m files is filled with pre written code (like the viewDidLoad), while mine is completely blank! Both our uitableviewcontroller.h files all have the code of
#import <UIKit/UIKit.h>
#interface ChemTable : UITableViewController
#property (strong,nonatomic)NSMutableArray *Chemarray;
#end
For learning purpose the auto-generated method are of least use(its perfectly ok even if You remove it). even you can create app without them....."viewDidLoad" is the one very necessary method that runs when the view is loaded, but when you go for real apps you will surely use some of auto-generated methods.
Extra -->I think you also also should see this:
ViewDidLoad - Called when you create the class and load from xib. Great for initial setup and one-time-only work
ViewWillAppear - Called right before your view appears, good for hiding/showing fields or any operations that you want to happen every time before the view is visible. Because you might be going back and forth between views, this will be called every time your view is about to appear on the screen
ViewDidAppear - Called after the view appears - great place to start an animations or the loading of external data from an API.
ViewWill/DidDisappear - Same idea as the WillAppear.
ViewDidUnload/Dispose - Available to you, but usually not necessary in Monotouch. In objective-c, this is where you do your cleanup and release of stuff, but this is handled automatically so not much you really need to do here.

Abandoned Memory, Leaks, Navigation Controller

I can't understand this behaviour in my app and I'm seriously thinking burn my mac NOW and start writing books of stories for children.
I have a normal Navigation Controller, and i push and pop viewcontrollers from it.
I'm doing a basic transition between views and I'm realising everything that I'm retaining or copying or whatever. But Instruments STILL identifies abandoned memory, and says that line is the responsible for that.
I can't understand. What I'm forgetting?
In Area2 I have few outles and one UIImageVIew, do I need to realising them to, in some way?
One more thing, if use Leaks inspector that same line is identified as a leak.. Really, I'm capable to destroy de entire world!
Please, can someone help me and tell me what I'm doing wrong and / or forgettting?
( Iniatly I had self.navigationController instead of delegate.navigationController, but the problems occurs to! )
Just this:
#import
#interface Area2 : UIViewController
{
IBOutlet UIButton * btBack;
}
# pragma mark - Navigation Controller
- (IBAction)goBack:(id)sender;
- (IBAction)goGaleria:(id)sender;
When I do Analyze ( Menu: "Product"->"Analyze" Xcode 4.2 ) give me build succeeded!
UPDATE:
SOLUTION is in the replies at #mit3z's answer! #babbidi answer!
If you have your outlets as properties and you don't release them in dealloc - then yes, you'll get a leak. It's hard to tell without seeing Area2 #interface declaration.

Made a change in Interface Builder, Xcode is not showing it

So here is what my interface looks like at the moment:
Here is what I have changed it to in Interface Builder:
This is what is shown after I run it in Xcode:
Obviously the two programs are not communicating - if someone could point me in the right direction it would be great.
Thanks heaps!
If stuff isn't in sync, try cleaning your build. Product>Clean should do the trick.
The programs communicate through the NIB/XIB files. Make sure you have saved your changes from Interface Builder before rebuilding in XCode (this does not happen automatically). Also double check that the file Interface Builder is editing is the exact same file (not a copy) of the one in your XCode project.
Hope this helps.
This happens if you rename a nib but forget to change name of nib name passed in to a ViewController in its initWithNibName: bundle initialiser.
For example. If I have a nib named ViewOne.xib which I'm passing in to a ViewController like this:
ExampleViewController *exampleViewController = [[ExampleViewController alloc] initWithNibName:#"ViewOne" bundle:nil];
And I change the name of the nib to ViewTwo, Xcode isn't smart enough to amend this reference in the initialiser, so now a xib that noi longer exists is being passed in to the ViewController. For reasons that I cannot fathom, despite the fact there is no longer a nib called ViewOne.xib, Xcode maintains some sort of ghost of the file and you won't get an error because of the missing nib. Cleaning and deleting derived data did not get rid of this ghost reference, at least in my case.
The fix is easy - just amend the nib name in the initialiser to your new name:
ExampleViewController *exampleViewController = [[ExampleViewController alloc] initWithNibName:#"ViewTwo" bundle:nil];