Xcode Storyboard Scrolling - xcode

is there a simple way in xcode storyboard to create a scrolling page including both text and images? Also, is this possible without using code? (Code is fine, but preferably none)

It's very simple but kind of impossible without coding although the code is very simple, just copy and paste this and you should be away.
This is for your ViewController .h
#interface ViewController : UIViewController
{
IBOutlet UIScrollView *Scroller;
}
This is for your ViewController .m under the super viewdidload
[Scroller setScrollEnabled:YES];
[Scroller setContentSize:CGSizeMake(320, 1000)];
Now all you need to do is add your UIScrollView onto your storyboard, in the view Controller scene click view controller, then just look in your outlets and connect them together by dragging from the word Scroller onto your UISCrollview

Related

how add a UIscrollView in a view controller ??

I have a view controller .h and .m and I don't know how
to add it to .xib
I pick a UIScrollView and I put it in the view of the .xib
but I can not relie his outlet to the declared UIScrollView in the viewController.h
Just trying to follow what you're trying to do. So you have presumably defined your UIScrollView in your header file as such:
#property(nonatomic, weak)IBOutlet UIScrollView *scrollView;
And now you need to link that to your XIB file? If you open the XIB file and click your main window of that view so the outside of it is selected, then you'll get properties available to you on the right hand side of your Xcode project. On the third tab the first field contains a place for you to select the UIViewController class you defined that UIScrollView. Select it. Then you can click+drag from your window to the UIScrollView in your XIB to connect it.

Can't CTRL+Drag NSButton to custom NSView header

I'd like to create a custom NSTableCellView instantiated by Interface Builder. I've set my Table Cell View class to MyTableCellView, and properly created MyTableCellView : NSTableCellView .m/.h files.
However, I just can't CTRL+Drag a simple button from inside this view to MyTableCellView.h in order to create an IBOutlet.
Here is a video to show what happens: http://youtu.be/sNNbuVT-SZs.
How the view is subclassed:
How I try to CTRL+Drag a button
Also, sometimes, Interface Builder just don't allow the cell view's class to be modified. What's happening ?
I finally found a solution, that is a little weird but works as expected. Instead of connecting the NSButton to MyTableCellView header directly, I used the reversed path:
Manually create an outlet:
#property(retain, nonatomic) IBOutlet NSButton* button;
Then click the empty circle on the left, and drag it to your XIB file's button:
I have no idea why it works this way, please let me know if you know the anwser.

How to refer to Cocoa controls located in in the same NSWindow?

I have a NSWindow with an NSView and an NSTextField inside.
I'm using Interface builder right now. I have dropped the two controls on the default NSWindow and subclassed an NSView. I'm implementing the -drawRect method from NSView and I need to access to the content of NSTextField.
How do I refer to the instance of NSTextField from a method inside the NSView ?
Your NSWindow is (or should be) controlled by a window controller. In IB you create an outlet for the NSTextField in your window controller. Using the outlet, you can then refer to the NSTextField:
In your window controller .h file:
#property (strong) IBOutlet NSTextField *myTextField;
In your window controller .m file:
#synthesize myTextField;
From there you can in your controller:
[[self myTextField] setEditable: NO];
A point to note is that you do not access the controls in a window directly from that window as windows (and all Cocoa controls for that matter) are statically stored in a XIB/NIB file. All access to controls (UI elements) is channelled through controllers (NSWindowController, NSViewController) which in turn are capable of loading XIB/NIB files.
Apple provides various samples in their docs on how to do this.

How to make UIScrollview with xCode 4.2 and storyboards

I am new to iOS Development and am wondering how to put a scrollview in a storyboard, using Xcode 4.2. I want the content to be 1280 by 460. This code all works well, but when I go to wire up the outlet, there is no file's owner, so i'm stumped. Here is the code I have:
in the .h file-
#import <UIKit/UIKit.h>
#interface ViewController : UIViewController {
IBOutlet UIScrollView *scrollView;
}
#end
and the .m, under viewDidLoad:
- (void)viewDidLoad
{
[scrollView setScrollEnabled:YES];
[scrollView setContentSize:CGSizeMake(1280,460)];
[scrollView setPagingEnabled:YES];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
If anyone could help me, that would be great!
Storyboards do not have a File's Owner. You need to use the View Controller to connect the Outlets instead. I.E. Drag to the View Controller in the same way you used to drag to the File's Owner.
OK, I figured it out. I just had to create a class for my view controller. I was trying to use files that were not part of a class that was a subclass of UIViewController.I had to create a new class, then copy the old code in and make my view controller's class that of the NEW files, and THEN wire up the outlets. I was changing the class to something that was not there. I then wired my outlet up to the scroll view I wanted. Thankfully, that part is finally over! Thanks for the suggestions, guys, I really appreciate it.
A good visual tutorial is in the current Stanford CS193p course for iOS 5 in iTunes U.
This course works mainly with storyboards and they cover among other things UIScrollViews

point of UIViewController in IB

What exactly is the point of adding a UIViewController in IB? There is no way to add code like you can if you create a viewController in Xcode? And if you can what is the advantage of doing it in IB.
And isn't the whole point of a MVC to seperate code into "modular" parts so why would add a ViewController in IB
Sometimes all you need is a UIViewController. But most times you would create a UIViewController subclass of your own (in IB).

Resources