I have copied the contents of SignView.h and SignView.m from an existing project.
However, the connections were included in the following attributes:
#property (weak, nonatomic) IBOutlet UILabel *signHereLabel;
#property (weak, nonatomic) IBOutlet UIButton *clearBtn;
#property (weak, nonatomic) IBOutlet UIButton *doneBtn;
#property (weak, nonatomic) IBOutlet UITextField *textfield;
#property (weak, nonatomic) IBOutlet SignatureView *signView;
#property(strong, nonatomic)IBOutlet UIView *contentView;
- (IBAction)clearBtnAction:(id)sender;
- (IBAction)doneBtnAction:(id)sender;
- (IBAction)backBtnAction:(id)sender;
- (IBAction)gestureAction:(id)sender;
Every time I check the UIView in the connection, it shows that it is connected to the other project xib file where the UIView class came from (which is weird).
If I remove the connections, it affects the other project instead of the current project I'm working on.
I'm pretty sure I created the file, copied the contents only and not the entire file, so the file is not a reference (supposed to be), but a real file.
Question
So, how do I remove the connection inside the contents of my copied SignView.h file. And how do I connect SignView.h in my current project properly?
Maybe the file you added are referenced from the source try to copy them when you add them to your project by :-
Edit
Another thing you can do is change the name of your IBActions and IBOutlets like nameLabel to nameLabelMyVc(according to your requirement) and then remove the reference from storyboard or nib whatever you're using and connect the fresh outlets that you've renamed.
Related
# of Images are placed in a View using Storyboard.
I want to manipulate them programmatically using a For loop. But couldn't find how to?
Currently i am using the following code:
#property (weak, nonatomic) IBOutlet UIImageView *img_level2;
#property (weak, nonatomic) IBOutlet UIImageView *img_level3;
#property (weak, nonatomic) IBOutlet UIImageView *img_level4;
#property (weak, nonatomic) IBOutlet UIImageView *img_level5;
#property (weak, nonatomic) IBOutlet UIImageView *img_level6;
#property (weak, nonatomic) IBOutlet UIImageView *img_level7;
...
...
...
_img_level2.image = [_img_level2.image convertToGrayscale];
_img_level3.image = [_img_level3.image convertToGrayscale];
_img_level4.image = [_img_level4.image convertToGrayscale];
_img_level5.image = [_img_level5.image convertToGrayscale];
_img_level6.image = [_img_level6.image convertToGrayscale];
_img_level7.image = [_img_level7.image convertToGrayscale];
Now instead of writing them line by line i want to use a for loop. Because this procedure might be called multiple times for sizing and positioning.
Please advice, thanks!
Instead of having each of the buttons as its own UIButton property, you can define an outlet collection, which is essentially an array that you'll be able to treat exactly as you want (for example, loop over all of its items).
How do you do that? Simple:
In your code, replace all of the IBOutlet UIImageView... lines with:
IBOutletCollection(UIImageView) NSMutableArray *imgLevels;
On InterfaceBuilder, give each of your UIImageViews a different tag that will match its index in the IBOutletCollection.
And, finally, when you connect the objects on your .xib or storyboard file, you'll notice it will appear on the Referencing Outlet Collections section instead of the Referencing Outlets as you're used to.
Now you have an array that you can use to loop over your IBOutlets exactly as you would loop a "regular" NSArray. Good Luck!
I am creating a iPad app, using XCode4 and Storyboard. I have the exact same app on a iPhone, which works just fine. I copied all of the controller's .h and .m files to the new iPad app. There are NO build errors. I am using custom cells in several UITableViews, with prototype cells.
I have 4 IBOutlets defined in a .h file, which is included in the UIView controller's .h file. I'm trying to connect the IBOutlets to the objects in the prototype cells, but when I click on the controller, the objects don't appear in the Inspector.
Any idea why?
UPDATE: here is the code for the SiteListingCell.h.
#import <UIKit/UIKit.h>
#interface SiteListingsCell : UITableViewCell {
}
#property (nonatomic, strong) IBOutlet UILabel *staLabel;
#property (nonatomic, strong) IBOutlet UILabel *descLabel;
#property (nonatomic, strong) IBOutlet UILabel *dateLabel;
#end
Make sure the class of the object you're trying to connect is set correctly in IB:
I have a simple project using Xcode 4.3.2 targeting iOS 5.1, using storyboards and a NavigationController. I have just migrated the project to use ARC and I'm now noticing that memory isn't being reclaimed when my UITableViewController scene is popped (back button pressed). I'm sure this was working OK when I was managing memory myself. I'm using the 'Allocations' feature of the Instruments tool and I can see the 'Live Bytes' continues to increase each time the scene is pushed then popped. The interface for the UITableViewController is :
#import <UIKit/UIKit.h>
#import "ASIHTTPRequest.h"
#interface StockListView : UITableViewController <UISearchBarDelegate>
{
NSMutableArray *tableListArray;
IBOutlet UISearchBar *searchBarControl;
}
#property (nonatomic) ASIHTTPRequest *httpDSRequest;
#end
The UITableView uses a custom UITableViewCell class defined as follows :
#import <UIKit/UIKit.h>
#interface StockListCell : UITableViewCell
#property (nonatomic) IBOutlet UILabel *lblStockCode;
#property (nonatomic) IBOutlet UILabel *lblDescription;
#property (nonatomic) IBOutlet UILabel *lblQtyInStock;
#property (nonatomic) IBOutlet UILabel *lblQtyFree;
#end
Is there something in the properties I'm using that is keeping the view controller retainined in memory? Do I need to add some code to allow the view controller to fully deallocate now that I'm using ARC?
I also used the 'Leaks' feature of Instruments but this didn't show up any leaks present.
Any help appreciated, apologies I'm still new to iOS development.
Thanks
Jonathan
You should make the buttons weak referenced
#property (weak, nonatomic) IBOutlet UILabel *lblStockCode;
And maybe have a look at this: ARC Transition
Just trying to make a simple WebView Mac app.
I've imported WebKit.h, declared a WebView #property, and #synthesized it in the .m, but when I go into IB and the connections tab, my outlet, say MyWebView, is not listed.
.h
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>
#interface MyAppDelegate : NSObject <NSApplicationDelegate> {
NSWindow *window;
IBOutlet WebView *MyView;
}
#property (assign) IBOutlet NSWindow *window;
#property (nonatomic, retain) IBOutlet WebView *MyView;
#end
.m
#synthesize MyView;
Latest version of Xcode. Thoughts?
Make sure that is defined like:
#property(nonatomic, retain) IBOutlet UIWebView *myWebView;
If you haven't added IBOutlet, IB won't show it as such.
After looking at the code you posted a little more carefully, I think the problem has to do with the name of your app delegate -- how (and why?) did you change it from the default AppDelegate? Is the blue cube in IB named AppDelegate or is it named MyAppDelegate? If it's the former, that's your problem -- change its class to MyAppDelegate in the Identity Inspector in IB.
See my comments on my original question. Error on my part.
I am having trouble testing equality on the Views that are set up in my project.
This is a long post, please bear with me. I have 3 separate views set up as part of the same XIB.
Each view is connected to File Owner (UIViewController) via an IBOutlet
The owner itself is a UIViewController
#interface PuzzleViewController : UIViewController {
Inside the FileOwner views are declared as:
IBOutlet Puzzle1 *p1;
IBOutlet Puzzle2 *p2;
IBOutlet Puzzle3 *p3;
#property (nonatomic, retain) IBOutlet Puzzle1 *p1;
#property (nonatomic, retain) IBOutlet Puzzle2 *p2;
#property (nonatomic, retain) IBOutlet Puzzle3 *p3;
Additionally i have
UIView *currentPuzzleView;
#property (nonatomic, retain) UIView *currentPuzzleView;
In .m file, upon initialization, i declare current view to be p1
[self setCurrentPuzzleView:p1];
Later, i would like to check if current view is in fact p1. This comparison fails.
if ([[self currentPuzzleView] isEqual:p1]) {
Additionally this fails as well
if ([self currentPuzzleView] == p1) {
Why is this?
Because you are using different classes for the equality test (UIView and Puzzle1). Your currentPuzzleView should be a pointer to one of those three classes Puzzle1 Puzzle2 Puzzle3. If you definitely need to use three different classes for those puzzle views, try adding tags to them and change
#property (nonatomic, retain) UIView *currentPuzzleView;
to
int currentPuzzleViewTag;
set it to 1 upon viewDidLoad: and change the tag to appropriate when different views are selected.
It's just a hunch but perhaps p1 is nil 'upon initialization'. It really depends on where you set currentPuzzleView to p1. It could be that the outlet points to nothing (yet).