【问题标题】:Change size of View in UYLModalViewController在 UYLModalViewController 中更改视图的大小
【发布时间】:2012-01-15 13:57:55
【问题描述】:

我创建了一个模态视图控制器。在我创建了 TableView 和 TextField

在垂直位置一切正常! Verticlal

但是在横屏上可以看到这一切

如何调整视图的大小?

这里是调用ModalView的代码

-(IBAction)buttonTapped:(id)sender{
    UYLModalViewController *modalVC = [[UYLModalViewController   alloc] initWithNibName:@"UYLModalViewController" bundle:nil];
    modalVC.delegate = self;

    UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:modalVC];
    if (modalViewShowType==1)
    {
        nc.modalPresentationStyle = UIModalPresentationFullScreen;
         [self presentModalViewController:nc animated:YES];
    }
    else{

        nc.modalPresentationStyle = UIModalPresentationFormSheet;
        nc.view.bounds = CGRectMake(0, 0, 320, 480);
        [self presentModalViewController:nc animated:YES];
        //nc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;  
        //nc.view.frame = CGRectMake(0, 0, 320, 480);//it's important to do this after presentModalViewController
        //nc.view.center = self.view.center;
    }



    [modalVC release];
    [nc release];

}

这里是modalView的控制器声明

@protocol UYLModalViewControllerDelegate

-(void) buttonDonePassed :(NSArray *) variables;


@end

@interface UYLModalViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, UITextFieldDelegate>
{ 

    id<UYLModalViewControllerDelegate> delegate;
    //id<UITextFieldDelegate> textdelegate;
   // id<UITextField> txt;
    IBOutlet UITableView *tblView;
    IBOutlet UITextField *textField;

    NSMutableArray *cellsArray;
    BOOL isAddedNewRow;
    //UITextField *textField;



}
- (UITableViewCell *) getCellContentView:(NSString *)cellIdentifier :(NSInteger *)cellRow;
//-(void) clickToTextField:(id)sender;
@property (nonatomic, assign) id<UYLModalViewControllerDelegate>    delegate;
@property (nonatomic, retain) IBOutlet UITableView *tblView;
@property (retain, nonatomic) IBOutlet UITextField *textField;


@end

正如我在调试模式下看到的,当设备处于水平位置时它不会转到 tableview 委托方法 =(

【问题讨论】:

  • 我认为你应该手动编写这个界面,而不是依赖于 Interface Builder,这对于非全屏视图来说是错误的。

标签: objective-c ios ipad xcode4 orientation


【解决方案1】:

1) 方法在哪里定义:

-(IBAction)buttonTapped:(id)sender;

我认为在

上呈现模态视图控制器存在问题

UISplitViewController...尝试将它呈现在另一个 ViewController 上进行测试

2) 如果使用不当,UISplitViewController 会产生一些问题

例子:尝试添加SubView它的视图(你不能推送它)

3) 使用 UYLModalViewController 视图的 auoresizeMask 进行验证

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多