我对Objective C非常陌生,并且试图创建一个只用一行代码初始化对象(按钮对象更加精确)的方法......我的方法声明......Objective C - 初始化对象时通过方法参数传递对象名的问题
- (void)buttonDeclaration: (UIButton *)mButton :(int)xloc :(int)yloc :(int)bWidth :(int)bHeight
: (NSString *)sImage :(UIViewController *)mView :(SEL)mSelector
{
mButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self buttonSetxy:mButton :xloc :yloc :bWidth :bHeight];
[mButton setBackgroundImage:[UIImage imageNamed:sImage] forState:UIControlStateNormal];
[mView.view addSubview:mButton];
}
我的方法调用...
[...buttonDeclaration:newButton :40 :65 :80 :65...]
,但是当我尝试添加
[newButton setHidden:FALSE];
我调用该方法后什么都不做。我不确定什么是适当的术语,但对象名称应该是newButton而不是mButton。这是否有意义,我该如何做到这一点?
buttonSetxy方法做什么???你是否正确设置了框架? – mayuur
buttonSetxy仅仅是改变我的按钮坐标的另一种自定义方法。同样,在我的主视图控制器中进行单线编码。 – leejhall
可以发布buttonSetxy的代码吗? Cz如果你不会设置btn的框架,那么它会添加wudnt。 – mayuur