[英]Instance method to return image parameters individual values
I want to get image parameters x and y in return by calling an instance method. 我想通过调用实例方法来获取图像参数x和y作为回报。 I need to send an integer value from 0 to 3, according to which corresponding result to fetched. 我需要发送一个0到3之间的整数值,根据该整数值提取相应的结果。 Below is the code i am trying to use. 以下是我尝试使用的代码。
-(int)imgSize:(int)y parameters:(int)m
{
if(n == 0)
{
return y= 320;
return m = 50;
}
if(n == 1)
{
return y= 728;
return m = 90;
}
if(n == 2)
{
return y= 300;
return m = 250;
}
if(n == 3)
{
return y= 468;
return m = 60;
}
return 0;
}
What i am not getting is how to send the value of n so that it can give required response. 我没有得到的是如何发送n的值,以便它可以给出所需的响应。 Please guide for the above. 请指导以上内容。 Thanks in advance. 提前致谢。
If i understood right, you confuse input with output, so: 如果我理解正确,则将输入与输出混淆,因此:
-(CGSize)imgSizeWithParameters:(int)n
{
CGSize m = CGSizeMake(0,0);
if(n == 0)
{
m = CGSizeMake(50,320);
}
else if(n == 1)
{
m = CGSizeMake(90,728);
}
else if(n == 2)
{
m = CGSizeMake(250,320);
}
else if(n == 3)
{
m = CGSizeMake(60,468);
}
return m;
}
for get the parameters: 获取参数:
CGSize size = [self imgSizeWithParameters:x]; //where x is 0,1,2 or 3
-(NSMutableArray*)imgSize:(int)y parameters:(int)m
{
if(n == 0)
{
NSMutableArray *tmpArray=[[NSMutableArray alloc]initWithObjects:[NSNumber numberWithInt:320],[NSNumber numberWithInt:50],nil];
return tmpArray;
}
if(n == 1)
{
NSMutableArray *tmpArray=[[NSMutableArray alloc]initWithObjects:[NSNumber numberWithInt:728],[NSNumber numberWithInt:90],nil];
return tmpArray;
}
if(n == 2)
{
NSMutableArray *tmpArray=[[NSMutableArray alloc]initWithObjects:[NSNumber numberWithInt:300],[NSNumber numberWithInt:250],nil];
return tmpArray;
}
if(n == 3)
{
NSMutableArray *tmpArray=[[NSMutableArray alloc]initWithObjects:[NSNumber numberWithInt:468],[NSNumber numberWithInt:60],nil];
return tmpArray;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.