Iphone UIButton在没有可见原因的情况下调整了大小?
我有ViewController(1),它的层次结构如下Iphone UIButton在没有可见原因的情况下调整了大小?,iphone,ios,objective-c,cocoa-touch,uibutton,Iphone,Ios,Objective C,Cocoa Touch,Uibutton,我有ViewController(1),它的层次结构如下 ViewController - UIView -- UITableView (height 80% of it's superview) -- UIButton ( height 20% of it's superview, 80% offset y) 按下UI按钮后,将按下新的ViewController。到目前为止,一切都很好,但在动画的那一刻,我看到UIButton的大小调整到适合整个视图。现在返回后,我在整个视图上有了我的按钮
ViewController
- UIView
-- UITableView (height 80% of it's superview)
-- UIButton ( height 20% of it's superview, 80% offset y)
按下UI按钮后,将按下新的ViewController。到目前为止,一切都很好,但在动画的那一刻,我看到UIButton的大小调整到适合整个视图。现在返回后,我在整个视图上有了我的按钮
什么会导致出现此问题
一,
编辑1:
- (void)viewDidAppear:(BOOL)animated
{
// ...
_storeButton = [[UIButton alloc] initWithFrame:frame];
_storeButton.adjustsImageWhenHighlighted = NO;
_storeButton.backgroundColor = [UIColor colorWithHexString:(_productData.count > 0) ? @"0x8BC53F" : @"0xA4A4A4" ];
[_storeButton addTarget:self action:@selector(storeButtonTouched:) forControlEvents:UIControlEventTouchUpInside];
// ...
}
#pragma mark - Store request.
- (void)storeButtonTouched:(id)sender
{
DLog(@"_storeButton: %@", _storeButton);
if ( _productData != nil && _productData.count > 0) {
_productData = [NSArray arrayWithArray:_iapManager.productData];
TTIAPTableViewController *iapVC = [[TTIAPTableViewController alloc] initWithStyle:UITableViewStylePlain];
iapVC.entries = _productData;
iapVC.contentSizeForViewInPopover = self.view.frame.size;
[self.navigationController pushViewController:iapVC animated:YES];
[iapVC release];
} else {
DLog(@"No products available.");
}
}
通过使用解决。是否使用自动布局?是否使用新的自动布局功能?如果是,请转到nib或stroyboard文件,转到“实用程序”面板(右侧)上的“文件检查器”部分。取消选中“使用自动布局”框。我既没有使用自动布局也没有使用自动调整mask。在视图中,
frame
的值是多少?
- (void)viewDidAppear:(BOOL)animated
{
// ...
_storeButton = [[UIButton alloc] initWithFrame:frame];
_storeButton.adjustsImageWhenHighlighted = NO;
_storeButton.backgroundColor = [UIColor colorWithHexString:(_productData.count > 0) ? @"0x8BC53F" : @"0xA4A4A4" ];
[_storeButton addTarget:self action:@selector(storeButtonTouched:) forControlEvents:UIControlEventTouchUpInside];
// ...
}
#pragma mark - Store request.
- (void)storeButtonTouched:(id)sender
{
DLog(@"_storeButton: %@", _storeButton);
if ( _productData != nil && _productData.count > 0) {
_productData = [NSArray arrayWithArray:_iapManager.productData];
TTIAPTableViewController *iapVC = [[TTIAPTableViewController alloc] initWithStyle:UITableViewStylePlain];
iapVC.entries = _productData;
iapVC.contentSizeForViewInPopover = self.view.frame.size;
[self.navigationController pushViewController:iapVC animated:YES];
[iapVC release];
} else {
DLog(@"No products available.");
}
}