Вы не передаете параметр.
У вас должно быть что-то вроде этого:
[self setClass1:[[[Class1 alloc] init] autorelease]];
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
//This
[[self horizontalTableView] setRowHeight:[class1 CellWidth:orientation]];
Причина, по которой ваша текущая реализация не вызывает эту функцию, заключается в том, что вы не говорите ей, чтобы она вызывала эту функцию. Вы говорите, чтобы позвонить [function CellWidth]
не [function CellWidth:orientation]
Судя по вашим отзывам, вам действительно нужно нечто подобное:
-(double)CellWidth {
double width = 0;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if(orientation == UIInterfaceOrientationPortrait) {
NSLog(@"PORTRAIT");
width = 153.6;
} else if(orientation == UIInterfaceOrientationLandscapeLeft ||
orientation == UIInterfaceOrientationLandscapeRight) {
NSLog(@"LANDSCAPE");
width = 204.6;
}
return width;
}
затем в вашей реализации, в Class2.m:
[self setClass1:[[[Function alloc] init] autorelease]];
//This
[[self horizontalTableView] setRowHeight:[class1 CellWidth]];
Чтобы сделать это еще яснее, я попытаюсь почистить это ...
CoolCellInfo.h
@interface CoolCellInfo : NSObject {
}
-(double)cellWidth;
@end
CoolCellInfo.m
@implementation CoolCellInfo
-(id)init {
self = [super init];
if(self) {
}
return self;
}
-(double)cellWidth {
double width = 0;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if(orientation == UIInterfaceOrientationPortrait) {
NSLog(@"PORTRAIT");
width = 153.6;
} else if(orientation == UIInterfaceOrientationLandscapeLeft ||
orientation == UIInterfaceOrientationLandscapeRight) {
NSLog(@"LANDSCAPE");
width = 204.6;
}
return width;
}
@end
CoolCellUser.h
#import "CoolCellInfo.h"
@interface CoolCellUser : NSObject {
CoolCellInfo *cellInfo;
}
@property (nonatomic, retain) CoolCellInfo *cellInfo;
@end;
CoolCellUser.m
@implementation CoolCellUser
@synthesize cellInfo;
-(id) init {
self = [super init];
if(self) {
double width = [[self cellInfo] cellWidth];
NSLog(@"Omg cell width = %f", width);
}
return self;
}
#pragma mark Lazy Loader
-(CoolCellInfo *)cellInfo {
if(cellInfo == nil) {
[self setCellInfo:[[[CoolCellInfo alloc] init] autorelease]];
}
return cellInfo;
}
@end