Reputation: 323
I have a custom UI Table Cell Code which is imported into the Controller. Within the Controller, I am looking to make some changes (change border, color, etc). I hookup the ref outlet in the XIB, but when I try to make changes in the Controller, nothing happens. Here is my Controller.m:
@synthesize btnExpDate;
- (void)viewDidLoad
{
[super viewDidLoad];
//detect iOS 7
NSString *ver = [[UIDevice currentDevice] systemVersion];
float ver_float = [ver floatValue];
if (ver_float >= 7.0) {
// adds border to borderless button for iOS 7
btnExpDate.layer.BorderWidth = 1;
btnExpDate.layer.CornerRadius = 4;
btnExpDate.layer.borderColor = [UIColor colorWithRed:230.0/255.0 green:230.0/255.0 blue:230.0/255.0 alpha:1.0].CGColor;
}
Controller.h
#import <UIKit/UIKit.h>
@class PullInventoryAddLotsTableCell;
@interface PullInventoryAddLotController : JCBaseController {
NSMutableArray* _newlyAddedLots;
}
@property (nonatomic, retain) IBOutlet UIButton* btnExpDate;
@end
Upvotes: 0
Views: 164
Reputation: 2973
Well i believe it has to do with your section of finding if it is iOS 7 or not...
//detect iOS 7
NSString *ver = [[UIDevice currentDevice] systemVersion];
float ver_float = [ver floatValue];
if (ver_float >= 7.0) {
This is not how you find out if it is iOS..to figure that out, you should use:
this is used by Apple, and is found in the iOS 7 UI transition guide
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
// Load resources for iOS 6.1 or earlier
} else {
// Load resources for iOS 7 or later
}
also, when dealing with these
// adds border to borderless button for iOS 7
btnExpDate.layer.BorderWidth = 1;
btnExpDate.layer.CornerRadius = 4;
btnExpDate.layer.borderColor = [UIColor colorWithRed:230.0/255.0 green:230.0/255.0 blue:230.0/255.0 alpha:1.0].CGColor;
you should either have a self. or _ in front of your variable considering they are auto-synthesized properties.. Also, your BorderWidth and CornerRadius shouldn't be caps started, they are borderWidth and cornerRadius. An easy typo :)
// adds border to borderless button for iOS 7
self.btnExpDate.layer.borderWidth = 1; // OR _btnExpDate.layer.borderWidth = 1;
self.btnExpDate.layer.cornerRadius = 4; // OR _btnExpDate.layer.cornerRadius = 4;
self.btnExpDate.layer.borderColor = [UIColor colorWithRed:230.0/255.0 green:230.0/255.0 blue:230.0/255.0 alpha:1.0].CGColor; // OR _btnExpDate.layer.borderColor = ...
Upvotes: 1