I'm making a app with mutiple view controllers, one moves on to the next and once the user moves on to the next view there is no need to go back.
I have created the .m .h files for the view controllers that I need to play sounds on.
What I would like help with is disabling copy/paste/define in UITextview which I know how to do (and works fine) using
#interface MyUITextView : UITextView {
}
#end
#implementation MyUITextView
- (BOOL)canBecomeFirstResponder
{
return NO;
}
Is there a way of using this code once with out creating .m .h files for each and every uiveiwcontroller?
Or will Xcode allow me to assign the same name to more than one uiveiwcontroller and use the same piece of code?
Is it possible to write it into the AppDelegate for every UITextview on different controllers?
Thanks for any help in advance :)
You don't have to duplicate any code. If you're making your UI using xib files or a storyboard, just set the class name of any text views that you want to have behave this way to MyUITextView in Xcode's Identity inspector.
Related
I have subclassed UICollectionView and assigned its delegate and datasource to an NSObject class. I use a custom UICollectionViewCellwith a .xib to construct the collection view's cells. The project can be found here:
https://github.com/JeffModMed/CustomUICollectionView
As you'll see, the datasource methods are working fine, but didSelectItemAtIndexPath and shouldSelectItemAtIndexPath are not called when the user taps on a cell, which leads me to believe there's something with UICollectionViewDelegate. The only other possible problem area I can think of is that there's something wrong with how I'm using the custom UICollectionViewCell class or registering its .xib file.
Note: Please don't answer suggesting that I use UICollectionViewController as an alternative: the code has to be done this way for incorporation with a larger project. Thanks in advance.
In the MMFilterTagCollectionViewCell.xib, select the cell and enable the User Interaction Enabled option.
In the MMFilterTagCollectionView.m file, comment out this line:
#synthesize delegate;
I am pretty new to xcode and for the life of me I cannot figure this one out. I am adding a view controller to a storyboard and I am trying to add a picker to that controller, I have the code in a header and main file I created but how do I link those files to the viewcontroller in my storyboard?
Here is how:
Create a custom UIViewController subclass for your code, eg MyViewController.h and MyViewController.m
in the storyboard drag out a ViewController
(i think you have done both of these steps)
in the Identity Inspector (panel 3 of left-hand side Utilities panels), under 'Custom Class' you should see your class in the scrolling list. Select it.
Then you will want to make links between your picker in the storyboard and your code....
I'm trying to subclass UISplitViewController to decrease the width of the master. I've looked at Matt Gemmell's MGSplitViewController - see Change the width of Master in UISplitViewController - but it looks like way more than I need. I just want to decrease the size of the master from 320 to 260 in a way that Apple will accept in the app store.
I'm new to subclassing anything other than a button, but this is what I'm trying so far, although it currently doesn't do anything. Either I'm way off the mark or I'm missing something simple. How can this be done?
Header file:
#import <UIKit/UIKit.h>
#interface MYSplitViewController : UISplitViewController
+ (CGFloat)masterColumnWidth;
#end
Implementation file:
#import "SRSplitViewController.h"
#interface SRSplitViewController ()
#end
#implementation SRSplitViewController
+ (CGFloat)masterColumnWidth {
return 260;
}
#end
I ended up not going this route, and would recommend against trying to subclass UISplitViewController for others. It's not a flexible layout so unless you want exactly what it provides out of the box, you are going to run into time-consuming problems.
If you want a side navigation bar similar to the Facebook app, I'd recommend using JASidePanels and placing whatever size and style view controller you want in the left panel.
I'm using XCode 4, and note that when setting up a new Cocoa Application project, you get an AppDelegate.m and .h file, as well as a .nib (.xib). Using alt-command-return, you get the 3-column editor layout, from which you can control-drag from controls to the AppDelegate.h file to create Outlets or Actions.
My question is, is it recommended to utilise these AppDelegate files to manage your interface controls ie. updating labels, acting on button presses etc. OR is it better to create an AppController class, add an object to the .xib and subclass it to AppController, modifying AppController to mange the controls? If this is the case, what are appropriate uses of AppDelegate?
I would like to say, it is just a matter of development style. What I do is use another class and change the AppDelegate to that class/view and use. Also I do not draw outlets and button on the default window. I make a view and add those as subviews to the mainWindow.
I am working on setting a uivewcontroller with 4 buttons which when i click will change the view underneath to different view. It could be either uitableview or just regular uiview with some text. I saw an answer here that i liked but i can't find it anymore. There is a way to split the views into different files so it will be more organized. I am using storyboards should i just bring 4 views on top of each other and then hide 3 of them? Also i am thinking to have a separate file for each so i can set them in the main view controller.
Also as far delegation. Do i need to set uitableview this way?
#interface PeopleTableView : UITableView <UITableViewDelegate, UITableViewDataSource>
and then create a separate protocol so that the mainviewcontroller can send the data to the peopletableview
Thanks!
yes exactly you can follow the general way to create you tableviews or so on , but in the cases like you there is a thing called tag is used. i'm sure you know.
so let's say for the tableviews , when you are in the row count , or setting the titles , you can firstly check the tableview's tag to learn which one is the enabled one.
hope this helps..