I have checked thoroughly for a solution to this (notably here: Can't connect IBOutlet in Interface Builder) but cannot see the solution. I have a UITextView that I am using as a text area in a form. I have connected it to this class member in IB:
IBOutlet UITextView *notes;
here is my .h
#import <UIKit/UIKit.h>
#import <AddressBookUI/AddressBookUI.h>
#interface U2MIDetailController : UIViewController <UITextFieldDelegate, UITextViewDelegate> {
IBOutlet UIButton *confirmButton;
IBOutlet UITextView *notes;
}
#property (nonatomic, retain) IBOutlet UITextView* notes;
#property ABRecordRef personObject;
#property (strong, nonatomic) IBOutlet UIScrollView *scroller;
#end
and my .m, the relevant bits:
#synthesize notes;
- (void)viewDidLoad
{
[super viewDidLoad];
//set up delegates for keyboard hiding
notes.delegate = self;
notes.text = #"Notes";
...
}
In the links I've found some have solved this issue by checking the File's Owner "Class" attribute on the Identity inspector. How do I do that? I have attached a pic of the hierarchy which looks correct to me, the identity inspector doesn't jump out at me either as having any suspicious properties.
Here is a shot of the storyboard:
and here is how it looks int he simulator:
check your scrollview frame either it is fit to frame or not. put blackground color you know where you did mistake
Related
So in the storyboard i have a UIViewController class called FormViewController. I set the ViewController in the storyboard to use that:
I then have the three text fields in the header file:
#import <UIKit/UIKit.h>
#interface FormViewController : UIViewController
#property (strong, retain) IBOutlet UITextView *firstName;
#property (strong, retain) IBOutlet UITextView *lastName;
#property (strong, retain) IBOutlet UITextView *email;
- (IBAction) save:(id)sender;
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender;
#end
However, when i try to connect the ones in the storyboard to the view controller, it doesnt pop up.
Any ideas?
UITextField and UITextView are two very different classes—you have created UITextField instances but your outlets are typed as UITextView.
Just change your outlet types to UITextField and all should be well!
(UITextView, for the record, is a scrolling, often editable field, more like a word processor.)
I can't figure out what is happening with my custom UITableViewCell.
The header file:
#import <UIKit/UIKit.h>
#interface CustomCell : UITableViewCell
#property (nonatomic, strong) IBOutlet UIImageView *imageView;
#property (nonatomic, strong) IBOutlet UILabel *personName;
#property (nonatomic, strong) IBOutlet UILabel *detailedTextLabel;
#property (nonatomic, strong) IBOutlet UILabel *amountLabel;
#end
The implementation file:
#import "CustomCell.h"
#implementation CustomCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {}
return self;
}
There is also a XIB file. The layout is an image view on the left and text and detailed text on the right.
Here is the problem. These custom cells are used in a UITableViewController. When I select one of the UITableViewCell, the imageView would shift to the right instead of being in the center when it initially gets loaded.
The most confusing thing is that the problem goes away if I add #synthesize to the implementation. As far as I know, the synthesize adds setter and getters however, in my implementation file, those properties are not set anywhere. They are an IBOutlet property so that my XIB can connect to them. Please tell me what might be going on?
Thanks!
There's no needs to synthesize the outlets. Seems like there are autolayouts enabled on xib file. Just disable them and try again.
Hey guys I am unable to find or connect my UITextField loginId with my custom viewcontroller.h file. when I try to get that class using NSString *data = loginId.text;it tells me that it is non existant.
.h file:
#import <UIKit/UIKit.h>
UITextField *loginId;
UITextField *password;
#interface loginController : UIViewController
- (IBAction) loginBegin:(id) sender;
#end
.m file:
NSString *intakePass = loginId.text;
I tried cleaning my project but that seems not to work. I notice that when I go to the storyboard to add in a custom class usually the classname I make in the .h file will drop down but nothing comes up. But it is set to loginId.
Suggestions, thoughts?
IBOutlet is the Key to Make them visible in XIB. So u must specify them as IBOutlet.
You must drag UITextField from library, not other components.Please verify it on XIB that you are connecting Text Field and make sure the class name of text field. it should be UITextField or UITextField Subclass.
#interface loginController : UIViewController{
IBOutlet UITextField *loginId;
IBOutlet UITextField *password;
}
#property(weak,nonatomic) IBOutlet UITextField *loginId;
#property(weak,nonatomic) IBOutlet UITextField *password;
- (IBAction) loginBegin:(id) sender;
#end
Apple Documentation says
IBOutlet your UITextField as below in your .m file:
#interface ViewController ()
#property(weak,nonatomic) IBOutlet UITextField *loginId;
#property(weak,nonatomic) IBOutlet UITextField *password;
#end
now you can connect your textfile in xib
I have a view controller alertForNeedsClassification as a property in another class, as such:
#interface SCAAppDelegate()
{
HomeScreenViewController * _homeScreenViewController;
NSInteger SCAStatus;
}
#property (strong, nonatomic) PromptClassifyViewController * alertForNeedsClassification;
#end
#implementation SCAAppDelegate
#synthesize alertForNeedsClassification;
#synthesize window = _window;
PromptClassifyViewController's interface looks like this:
#interface PromptClassifyViewController : UIViewController
#property (weak, nonatomic) IBOutlet UILabel *headerTitle;
#property (weak, nonatomic) IBOutlet UITextView *message;
#property (weak, nonatomic) IBOutlet UIButton *notNowButton;
#property (weak, nonatomic) IBOutlet UIButton *classifyButton;
#property (weak, nonatomic) IBOutlet UIImageView *backgroundImageView;
#property (weak, nonatomic) IBOutlet UIView *alertView;
#property NSUInteger tag;
#property (weak, nonatomic) IBOutlet id<PromptClassifyViewControllerDelegate> delegate;
- (void)show;
- (void)showFromView:(UIView *)view;
- (IBAction)show:(id)sender;
- (IBAction)dismiss:(id)sender;
- (IBAction)buttonWasPressed:(id)sender;
- (void)setHeaderTitleWithText:(NSString *)text;
#end
I am trying to change the values of IBOutlets message and headerTitle text, like this:
alertForNeedsClassification = [[PromptClassifyViewController alloc] initWithNibName:#"PromptClassifyViewController" bundle:nil];
//[alertForNeedsClassification setDelegate:self];
self.alertForNeedsClassification.headerTitle.text = #"A title";
alertForNeedsClassification.message.text = #"A message";
Then I show alertForNeedsClassification calling a show method (it's like a custom uialertview, but it doesn't subclass from uialertview).
Thing is, no matter how I change it, the text on alertForNeedsClassification.view is always that which is defined in the nib, ie. I can't change it programmatically.
My custom alert view is based on Jeff LaMarche's design: http://iphonedevelopment.blogspot.com/2010/05/custom-alert-views.html
Any ideas what might be going on?
Please be careful when you allocate and initialize the UIView object, especially if you trying to mix using Nib and dynamically generating objects. The best place is within -(void)awakeFromNib or -(void)viewDidLoad
Also, make sure these methods are called. By using -(id)initWithNibName:bundle: only cannot make sure your view to be loaded. Try -(void)addChildViewController and -(void)addSubview: on parentViewController's view to make sure view is loaded after being initialized.
If the text had to be prepared before being loaded, assign it to separate NSString property within PromptClassifyViewController class. Since this property is independent from view being loaded, you can change it's value BEFORE view is appeared. Make sure this text is used and applied to the headerTitle within -(void)show method.
Since you allocate PromptClassifyViewController and access weak referenced headerTitle from self. alertForNeedsClassification, make sure it's not deallocated right afterward.
Usually, weak option is not used for IBOutlet properties. Though it is used when generating outlet connection code by dragging objects from Interface Builder. Try testing your code using strong.
I was assigning values to the IBOutlets before they were alloc'd/initialized. The solution I implemented was to set the values I needed to non-IBOutlet properties (NSStrings in this case) and assign those where needed, in Prompt...Controller's viewDidLoad;
I have created one segmented control and a text view in my .xib file and I have declare it in .h file as
#interface controlsViewController : UIViewController {
IBOutlet UISegmentedControl *colorChooser;
IBOutlet UITextView *setText;
}
#property (nonatomic,retain) UISegmentedControl *colorChooser;
#property (nonatomic,retain) UITextView *setText
but it shows me warning on both lines of #property
Can anyone tell me why it warns me?
My guess would be that you don't have a #synthesize or #dynamic in your implementation. That would generate compiler warnings.
The position of the IBOutlet wound not generate a compiler warning as it's a marco of nothing. It's used by xcode resource editor (or the older Interface Builder) to indicate it's a outlet property and doesn't generate any code.
#interface controlsViewController : UIViewController {
UISegmentedControl *colorChooser;
UITextView *setText;
}
#property (nonatomic,retain) IBOutlet UISegmentedControl *colorChooser;
#property (nonatomic,retain) IBOutlet UITextView *setText;
You need to synthesize the property in your .m file. You won't get the error then.