0
在這裏,我想加上兩粒扣viewforprofileandsetting看法,但下面的代碼無法正常工作:的UIButton不加入上的UIView
(UIView *)viewForProfileAndSettingButton
{
setingAndProfileView=[[ UIView alloc ]initWithFrame:CGRectMake(0,_listView.frame.size.height, _listView.frame.size.width, _listView.frame.size.height/4)];
setingAndProfileView.backgroundColor=[ UIColor darkGrayColor ];
profileViewButton=[[ UIButton alloc ]init];
profileViewButton =[ UIButton buttonWithType:UIButtonTypeRoundedRect];
profileViewButton.backgroundColor=[ UIColor whiteColor ];
[ profileViewButton setTitle:@" profile View" forState:UIControlStateNormal ];
profileViewButton.frame=CGRectMake(setingAndProfileView.frame.origin.x+5, setingAndProfileView.frame.origin.y+10, setingAndProfileView.frame.size.width/2-50, setingAndProfileView.frame.size.height/2+10);
settingButton=[[ UIButton alloc ]init];
settingButton.backgroundColor=[ UIColor whiteColor ];
settingButton=[ UIButton buttonWithType:UIButtonTypeRoundedRect ];
settingButton.frame=CGRectMake(profileViewButton.frame.origin.x+profileViewButton.frame.size.width+10, setingAndProfileView.frame.origin.y+10, setingAndProfileView.frame.size.width/2-50, setingAndProfileView.frame.size.height/2+10);
[ settingButton setTitle:@" setting View" forState:UIControlStateNormal ];
[ setingAndProfileView addSubview:profileViewButton ];
[ setingAndProfileView addSubview:settingButton ];
return setingAndProfileView;
}
在哪裏,你怎麼樣聲明的每個上述意見/按鈕?另外,請解釋上述代碼如何不起作用,如預期的和實際的結果。 – ZeMoon
設置y座標正確。如果將其設置爲0或更小,則查看高度將會很好 –